kplonk
asked on
Best way to get a single row
Hi, if I have a stored procedure that when executed will return one row, with three columns, what is the best way to get the data from this. At the mo I have a sqldataadapter filling a dataset, but ho do I get the data from there, I want three vars say v1,v2 and v3 to be populated with the string vals in the row?
Thanks Kieran.
Thanks Kieran.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Thanks just what i wanted
Anytime. Glad to help.
Cheers,
Greg
Cheers,
Greg
string col1, col2, col3;
SqlCommand cmd = new SqlCommand("storedProcedur
cmd.CommandType = CommandType.StoredProcedur
connectionObject.Open();
SqlDataReader dr = cmd.ExecuteReader();
dr.Read();
col1 = dr.GetString(0);
col2 = dr.GetString(1);
col3 = dr.GetString(2);
dr.Close();
connectionObject.Close();