-
sql select statement
Hi gurus
I posted this question on .net forum ealizing it was the wrong forum too late, my apol.to the .net forum.
here is my question.
I have a select statement (select * from table) how can I check if the select statement ruturn a row,rows or nothing.
Thanks gurus
-
Re: sql select statement
Please show us the code you are using to actually execute that select statement.
-
Re: sql select statement
thanks for the help
I have so far the following
Code:
stringcommand1=select * from table where field = variable
osqlcommand = New SqlCommand
osqlcommand.CommandText = stringcommand1
osqlcommand.CommandType = CommandType.Text
osqlcommand.Connection = osqlconn
osqlcommand.ExecuteNonQuery()
I need to check if my select statement return any rows as sometimes there is no value to be returned from my table
Thanks again
-
Re: sql select statement
Using a ExecuteNonQuery command is normally used to update data, delete data or preform some other Data Definition Language on the database. To return data you normally use a Datareader or a Dataset. If you use a datareader you can use the .HasRows() property to see if any rows are returned from the database.
-
Re: sql select statement