Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Executing Stored Procs With Params
Message
General information
Forum:
ASP.NET
Category:
Databases
Miscellaneous
Thread ID:
00979533
Message ID:
00979535
Views:
16
Hey, Kevin,

There are a number of ways you can do this. If you have a SQL back-end and want to return the result into a dataset, the following example can work:
string cConnectStr	= "user id=sa;password=;initial catalog=Mydatabase;data source=MyServer"; 
SqlConnection oSqlConn = new SqlConnection(cConnectStr);
DataSet DsMyData = new DataSet();
SqlDataAdapter oSqlAdapter = new SqlDataAdapter(cMyStoredProcName, oSqlConn);

SqlParameter parmID = new SqlParameter("@nCustID",SqlDbType.Int);    // ncustID is the actual parameter name in the SP
parmID.Value = nCustId;    // nCustID is the integer containing the value you want to pass

oSqlAdapter.SelectCommand.CommandType = CommandType.StoredProcedure;
oSqlAdapter.SelectCommand.Parameters.Add(parmID);
oSqlAdapter.Fill( DsMyData,"MyDataSet");
oSqlConn.Close();
Again, there are many different ways, and you'd want to abstract out the connection object handling and other things, but hopefully that should give you an idea. If you had two parameters, you'd create a second parameter object and add it.

Hope that helps,
Kevin
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform