Need Store Procedure Help in ADO.NET 2.0 badly!

  • Thread starter Thread starter David Hearn
  • Start date Start date
D

David Hearn

I have two stored procs that I need to call in an ASP.NET 2.0 application
that I am writing. One has two input parameters that need to be sent and it
will return another. The other one also has two inout parameters and I need
to return a dataset from it. This was so simple in 1.1 through drag-and-drop
and it seems like they have made it harder in 2.0. I could drag-and-drop my
stored proc and it would automatically setup my data adapter and everything.
I can't find a way to do this in 2.0. I have searched all over for
tutorials, documentation, etc on how to accomplish this but I'm coming up
empty. Can someone enlighten me on how to accomplish these two tasks?
Detailed example code would be greatly appreciated as would links to
tutorials or other documentation.

Thanks in advance!
 
David - are you asking basically how to call a stored proc with Parameters
and return a query, and then how to grab an output parameter? If so, check
out www.betav.com -> Articles -> MSDN - Retrieving the Gozoutas by Bill
Vaugh.

To fill a dataset you just do this
SqlConnection cn = new SqlConnection("ConnectionString");
SqlCommand cmd = new SqlCommand("storedprocedurename", connection);
cmd.Paramaters.Add("FirstparamName", Value);// there are multiple overloads
here but this is one of the simpler ways.
cmd.Parameters.Add("SecondParamName", Value2);//ditto
SqlDataAdapter da = new SqlDataAdapter(cmd);
MyNewDataSet ds = new MyNewDataSet();
da.Fill(ds.TableName);
 
Thanks W.G. !

W.G. Ryan - MVP said:
David - are you asking basically how to call a stored proc with Parameters
and return a query, and then how to grab an output parameter? If so,
check out www.betav.com -> Articles -> MSDN - Retrieving the Gozoutas by
Bill Vaugh.

To fill a dataset you just do this
SqlConnection cn = new SqlConnection("ConnectionString");
SqlCommand cmd = new SqlCommand("storedprocedurename", connection);
cmd.Paramaters.Add("FirstparamName", Value);// there are multiple
overloads here but this is one of the simpler ways.
cmd.Parameters.Add("SecondParamName", Value2);//ditto
SqlDataAdapter da = new SqlDataAdapter(cmd);
MyNewDataSet ds = new MyNewDataSet();
da.Fill(ds.TableName);
 
Back
Top