Hello
This may be a naive question but since this is getting started section I will ask it. I have a web site with some pages having VB as coding language while others in C#. The problem is when i try to use theItem property of SqlDataReader I get "not defined" error. No such error with similar usage in VB. The property should exist in C# according to class library. What am i doing wrong?
SqlDataReader objDR;
objDR = selectCommand.ExecuteReader();
objDR.Item("ColumnName");
C# uses square brackets for indexers. Also, you are trying to access the property but are not doing anything with it. Try it like this instead:String myColumnData = objDR.Item["ColumnName"];
Hello Terri
thanks for your response. I tried your code and it still gives me the following error.
Error 1 'System.Data.SqlClient.SqlDataReader' does not contain a definition for 'Item' C:\***.dev\DeleteListingRequest.aspx.cs 27 49 C:\carolinamls.dev\
Also intellisense does not contain Item when I type a period (.) in the following line
String myColumnData = objDR. (prompt box does not contain Item in it)
I checked System.Data.SqlClient.dll v2.0.0.0 using Lutz Roeder's refletor and it does contain .Item(String/int32) property.
This works
string mycolumndata =Convert.ToString (objDR["columnname"]);
0 comments:
Post a Comment