Problems with no rows returning from Query and C#

B

Bill Gower

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
 
C

Cor Ligthert [MVP]

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top