Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Call Stored Proc And Return DataSet
Message
From
06/11/2008 09:56:25
 
General information
Forum:
ASP.NET
Category:
ADO.NET
Environment versions
Environment:
C# 3.0
OS:
Vista
Network:
Windows 2003 Server
Database:
MS SQL Server
Miscellaneous
Thread ID:
01359938
Message ID:
01360166
Views:
8
For anyone interested, check out Microsoft's data application block. The use of it really simplifies and greatly reduces the number of lines of code that need to be written to read and write data to the database. It may take a little bit to understand/set-up but once in place it is a breeze.

http://msdn.microsoft.com/en-us/library/cc309504.aspx






>I'm using C#/. I want to call a SQL stored procedure, pass parameters, and return a DataSet. Here's what I have so far:
>
>
>SqlCommand oCommand = new SqlCommand("bm_GetProjects", oConn);
>oCommand.CommandType = CommandType.StoredProcedure;
>
>SqlParameter param1 = new SqlParameter();
>param1.DbType = DbType.Int32;
>param1.Direction = ParameterDirection.Input;
>param1.ParameterName = "@AppKey";
>param1.SourceColumn = "AppKey";
>param1.SqlDbType = SqlDbType.Int;
>param1.Value = 87;
>oCommand.Parameters.Add(param1);
>
>
>SqlParameter param2 = new SqlParameter();
>param2.DbType = DbType.Int32;
>param2.Direction = ParameterDirection.Input;
>param2.ParameterName = "@CategoryTypeKey";
>param2.SourceColumn = "CategoryTypeKey";
>param2.SqlDbType = SqlDbType.Int;
>param2.Value = 87;
>oCommand.Parameters.Add(param2);
>
>
>
>SqlParameter param3 = new SqlParameter();
>param3.DbType = DbType.Int32;
>param3.Direction = ParameterDirection.Input;
>param3.ParameterName = "@ProjectStatusCodeKey";
>param3.SourceColumn = "ProjectStatusCodeKey";
>param3.SqlDbType = SqlDbType.Int;
>param3.Value = 87;
>oCommand.Parameters.Add(param3);
>
>
>oDataSet = oCommand.;       // ***  WHAT GOES HERE??? ***
>
>
>
>All the examples I found return a DataReader. How do I get back a data set?
>
>Also, do I need to set all those properties on each parameter object?
>
>Thanks
Previous
Reply
Map
View

Click here to load this message in the networking platform