views:

106

answers:

3

Hi I've been through many sites and can't seem to find an answer.

I modified a view that was connected to a Datagridview connected through a tableadapter on a C# Winforms app and in order to "reconnect" I had to delete the tableadapter and reconnect it. This was to get rid of an error regarding Unique contstraints. So I fixed that and now the application launches but when I click on the tab that that grid is on I get:

System.ArgumentException was unhandled
  Message="Cannot bind to the property or column Id on the DataSource.\r\nParameter name: dataMember"
  Source="System.Windows.Forms"
  ParamName="dataMember"
  StackTrace:
       at System.Windows.Forms.BindToObject.CheckBinding()
       at System.Windows.Forms.BindToObject.SetBindingManagerBase(BindingManagerBase lManager).........

I can't seem to find an answer to this problem. Can someone help me?

Thanks

A: 

First, I noticed from the title of this post you are seeing this exception at application.Run which means it probably got thrown a lot higher up the callstack. Can you go to Debug->Exceptions on the menu and set to Break on exceptions when thrown. This will help you isolate exactly when this is happening. It sounds like there is binding information setup and you remeoved one of the properties the grid is trying to bind to.

Steve Sheldon
I set the Exceptions to when thrown but it still stops in the same place. This time it is Green instead of yellow like a normal un handled exception. It says "This is the next statement to execute...." This is baffling me because I don't understand why it is stopping in that location...the app does launch it's just when I click on the tab with the disconnected data set that it Throws the error. Once the Error is thrown stepping in causes the application to crash after going through a bunch of initialization code.
Can you examine the full exception and get the full stack trace out of it, this might help find where the problem is. If you can post that stack trace that would be helpful too
Steve Sheldon
I was mistaken that I solved the issue it keeps coming back. I ran the full execption as best I could but I don't see anything that helps. Here is the exception:Exception (0)[System.Windows.Forms] System.ArgumentException : Cannot bind to the property or column Id on the DataSource.Parameter name: dataMember at System.Windows.Forms.BindToObject.CheckBinding() at System.Windows.Forms.BindToObject.SetBindingManagerBase(BindingManagerBase lManager)This is all I could input the form doesn't allow any more :-(
Ok so this time I really figured it out. See answer below.
A: 

I have solved the issue though I don't like my solution. I deleted the TableAdapter again and renamed it this time. Then I renamed all instances of the original name (all 192 of them even though I had deleted the adapter and recreated there were 192 of them still around! I then had to fix the query because I had renamed all the instances and I used the viewname as the TableAdapter name as it was the default. Hope this helps someone.

A: 

If you change the schema on a grid or within a view and refer to a field that no longer exists you get:

System.ArgumentException : Cannot bind to the property or column Id on the DataSource.Parameter name: dataMember

The column name that you are missing is listed after the word column. I was missing the column "ID". I thought I was unable to bind to the property or column Id eg. I read the error. Solved from someone else having the same issue being unable to bind to column ALBUM.

I think if the error had come from somewhere closer to the Grid building code instead of Application.Run I may have seen it. Maybe even if it errored at the binding of the grid / text box to the ID field I would have seen it trying to do something with the ID field and figured out it wasn't there. Oy Vay :-)