I have code as follows

if((DataTable)read_union_database("retrieveSSN")).row[0][0] == DBNull.Value
{
orow[0] = ""
}
else{
orow[0] = ((Data
Table)read_union_database("retrieveSSN")).rows[0][0].ToString();
}


I keep getting the error "There is no row at position 0" and when I place
debug statements in the code it never goes to the If side of the statement.
The read_union_database is just a SQL query
that returns back the SSN of a member that matches a certain parameter. So
in this case obviously I don't have a match and therefore I don't have a row
being returned. What is the proper way in C# to check to see if that
returned?

Bill

Re: Problems with no rows returning from Query and C# by Plamen

Plamen
Fri Jan 26 20:16:10 CST 2007

Hi Bill,

You can check the DataTable.Rows.Count property. If greater than 0 then you
have some rows returned, otherwise there are no rows.

Regards,

Plamen Ratchev
http://www.SQLStudio.com



Re: Problems with no rows returning from Query and C# by Cor

Cor
Sun Jan 28 04:32:42 CST 2007

Bill,

Is there any reason that there should be a row at position 0 from orow.

I can not get this from the code that you show.

Cor

"Bill Gower" <billgower@charter.net> schreef in bericht
news:u4$IbObQHHA.3412@TK2MSFTNGP05.phx.gbl...
>I have code as follows
>
> if((DataTable)read_union_database("retrieveSSN")).row[0][0] ==
> DBNull.Value
> {
> orow[0] = ""
> }
> else{
> orow[0] = ((Data
> Table)read_union_database("retrieveSSN")).rows[0][0].ToString();
> }
>
>
> I keep getting the error "There is no row at position 0" and when I place
> debug statements in the code it never goes to the If side of the
> statement. The read_union_database is just a SQL query
> that returns back the SSN of a member that matches a certain parameter.
> So in this case obviously I don't have a match and therefore I don't have
> a row being returned. What is the proper way in C# to check to see if
> that returned?
>
> Bill
>
>