开发者

ArgumentException was unhandled Application.run

开发者 https://www.devze.com 2023-01-03 16:56 出处:网络
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 \"reco

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 p开发者_开发百科roperty 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


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.


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.


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 :-)

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号