Can You Run a Stored Procedure Using SQLDataAdapter?

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hi.

Is it possible to run a Stored Procedure that takes 1 parameter using the
SQLDataAdapter. I'm currently using the SQLCommand with the SQLDataReader to
do this but would like to use a disconnected recordset.

Maybe a way to do this is to use the SQLCommand and then set a DataTable to
the
SQLDataReader. I played around with this approach for awhile but could not
get it to work.

Any suggestions will be greatly appreciated!

Rita
 
Could be like this

SqlCommand1.CommandText = "spRetrieveÝnfo";
SqlCommand1.CommandType = CommandType.StoredProcedure;
SqlCommand1.Connection = myConnection;
SqlCommand1Parqameters.Add(/////your parameters)

private void DataAdapterWithStoredProcedure()
{
DataSet ds = new DataSet();
//Assume da is your DataAdapter
da.SelectCommand = SqlCommand1;
da.SelectCommand.Parameters.[0].Value = "YourValue";
da.Fill(ds);
}

Hope this Helps
 
Back
Top