Reading multiple fields from database

CookieNZ

Member
Joined
Nov 24, 2005
Messages
17
Programming Experience
Beginner
I have a simple query that returns the data in a field.

selectstring = ("select invoicecompleted from mainjobdetails where jobno='" & jobnumber & "'")


cmdselect = New SqlCommand(selectstring, dbconnection)


status = cmdselect.ExecuteScalar()

I have a simple query that returns the data in a field. I then use the 'status' in an IF loop

However, I now need to return 2 fields in the query

selectstring = ("select invoicecompleted,iscancelled from mainjobdetails where jobno='" & jobnumber & "'")

I could bind the data to a grid and use it that way, but is there not a more simple way of capturing the 2 fields for use in the IF loop


 
you can ask the database to combine them if youre prepared to split it out at the end.. ultimately though, wouldnt you be better off writing a method that could query any number of columns and return them as an array?
 
If all you are going to get it one row (or even just a couple of rows) then a reader might be the best option, then get the data into variables. From there you can do what ever you need to with them.

-tg
 
Back
Top