John500
asked on
Proper way to extract data from a SqlDataReader object
I would like to know the best way to get the data from the SqlDataReader below:
SqlDataReader qvr= null;
q_Command.CommandText = "select * from users where username = @username ";
q_Command.Parameters.Clear ();
q_Command.Parameters.Add(" @username" , SqlDbType.VarChar).Value = SqlUserName;
qvr = q_Command.ExecuteReader();
qvr.Read();
At this point, how would I assign the contents of qvr to various text boxes on my form? I have ten boxes I need to populate with the contents of qvr.
Thanks!
SqlDataReader qvr= null;
q_Command.CommandText = "select * from users where username = @username ";
q_Command.Parameters.Clear
q_Command.Parameters.Add("
qvr = q_Command.ExecuteReader();
qvr.Read();
At this point, how would I assign the contents of qvr to various text boxes on my form? I have ten boxes I need to populate with the contents of qvr.
Thanks!
ASKER
Thanks!
So in other words it would be 0 - 10 using your lines below:
mytextbox1.Text = qvr[0].ToString(); // you could also say qvr["columnname"].ToString ();
mytextbox2.Text = qvr[1].ToString(); // index is order of the fields returned in query
Yes?
So in other words it would be 0 - 10 using your lines below:
mytextbox1.Text = qvr[0].ToString(); // you could also say qvr["columnname"].ToString
mytextbox2.Text = qvr[1].ToString(); // index is order of the fields returned in query
Yes?
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Yea, got it :) Thanks
{
mytextbox1.Text = qvr[0].ToString(); // you could also say qvr["columnname"].ToString
mytextbox2.Text = qvr[1].ToString(); // index is order of the fields returned in query
}