I've encountered a very, very strange situation in my application. I say strange because the errors are intermitent and I cannot find out why they occur.
I've pass a sqlcommand to the DB (Sql 2005) trying to get a bigint (column ID_Facultate) from a single table. The problem is that I've got a string (the name of some lecture) that has nothing to do with the table I've tried to access.
Also, when I get these errors, all my application is going crazy.
In the SQL Profiler everything seems fine (the last executing rows seem to be the ones sent by my application)
Here are some links to 3 captured screens during the errors and the code I've used. Please note the Watch1 with the very wrong string value where I expected some integer
- http://www.unitbv.ro/cata/errors/2.jpg
- http://www.unitbv.ro/cata/errors/3.jpg
- http://www.unitbv.ro/cata/errors/1.jpg
Updates:
I will consider using both the name of the column and/or ExecuteScalar.
Still, the problem is, as seen in the Watch1 that the query returns a value that has nothing to do with that table.
The code was expecting an integer (14) while the DB returned a string... (http://www.unitbv.ro/cata/errors/2.jpg) The same in http://www.unitbv.ro/cata/errors/3.jpg : I was expecting a value from 1 to 20 while the DB/layer seems to return the value 305 which is not in that table...
In the following post (various forums) I asked the same or related questions (and no positive answer yet)
- http://social.msdn.microsoft.com/Forums/en-US/sqldataaccess/thread/a9010d27-49ca-4cce-93a5-f3c4d62e4010
- http://social.msdn.microsoft.com/Forums/en-US/sqldataaccess/thread/6191a59b-40cb-49f2-9f59-e9ee1bf2c683/
- https://stackoverflow.com/questions/843496/please-help-with-system-data-datarowview-does-not-contain-a-property-with-the-n
- http://forums.asp.net/t/1432140.aspx
- http://forums.asp.net/t/1426029.aspx
- http://forums.asp.net/t/1420133.aspx