Jump to content
Xtreme .Net Talk

Recommended Posts

Posted

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 ?) ?

  • Administrators
Posted

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.

Posting Guidelines FAQ Post Formatting

 

Intellectuals solve problems; geniuses prevent them.

-- Albert Einstein

Posted

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.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...