Following problem:
I try to select records where a field is null.
i.e.:
MyCommandGeneric.CommandText = "select A, b from object where C is null";
MyDataReader = MyCommandGeneric.ExecuteReader();
If I try now to access the values (string bla = MyDataReader["A"]), I am
getting the error, that datareader can't read, when there is no data.
But there is data!
I tried to query the sql server directly with the above query, and it gives
a record.I think you have to execute read method before accessing the data.
SqlDataReader Class
http://msdn.microsoft.com/library/d...opi
c.asp
AMB
"the friendly display name" wrote:
> Following problem:
> I try to select records where a field is null.
> i.e.:
> MyCommandGeneric.CommandText = "select A, b from object where C is null";
> MyDataReader = MyCommandGeneric.ExecuteReader();
> If I try now to access the values (string bla = MyDataReader["A"]), I am
> getting the error, that datareader can't read, when there is no data.
> But there is data!
> I tried to query the sql server directly with the above query, and it give
s
> a record.|||Oh, good god.
Of course! Now it works.
"Alejandro Mesa" wrote:
> I think you have to execute read method before accessing the data.
> SqlDataReader Class
> http://msdn.microsoft.com/library/d...o
pic.asp
>
> AMB
> "the friendly display name" wrote:
>
Sunday, February 12, 2012
asp.net datareader+sql server+null fields=error
Labels:
aspnet,
commandtext,
database,
datareadersql,
field,
fieldserror,
following,
microsoft,
mycommandgeneric,
mysql,
null,
object,
oracle,
problemi,
records,
select,
server,
servernull,
sql
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment