CLRBOY Posted January 30, 2005 Posted January 30, 2005 Hi everybody :D I'm trying to execute a SP that selects rows. the problem is that i don't know how to get the results of the SP. I mean that the TSQL statement works fine in the query analyner but not in the WinApp. sqlCommand1.Parameters["@student_id"].Value = ID; sqlCommand1.Parameters["@first_name"].Value = f_name; sqlCommand1.Parameters["@last_name"].Value = l_name; sqlCommand1.ExecuteReader(); I assume that i shuld use the ExecuteReader ? am I right ? :( :confused: so how do i get the rows that were selected ? (in order to show them to the user ?) ? Quote
Administrators PlausiblyDamp Posted January 30, 2005 Administrators Posted January 30, 2005 Depends what you want to do with the result. If you want to use a DataReader to loop over the records then something like the following should help. System.Data.SqlClient.SqlDataReader dr = sqlCommand1.ExecuteReader(); while (dr.Read) { //do stuff with data here } or you may want to look at Datasets and DataAdapters as an alternative. Quote Posting Guidelines FAQ Post Formatting Intellectuals solve problems; geniuses prevent them. -- Albert Einstein
CLRBOY Posted January 30, 2005 Author Posted January 30, 2005 10x....... it so simple........... Depends what you want to do with the result. If you want to use a DataReader to loop over the records then something like the following should help. System.Data.SqlClient.SqlDataReader dr = sqlCommand1.ExecuteReader(); while (dr.Read) { //do stuff with data here } or you may want to look at Datasets and DataAdapters as an alternative. Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.