Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Stored Procedures Parameters
Message
General information
Forum:
ASP.NET
Category:
Coding, syntax and commands
Title:
Stored Procedures Parameters
Environment versions
Environment:
C# 3.0
OS:
Windows XP SP2
Network:
Windows 2008 Server
Database:
MS SQL Server
Miscellaneous
Thread ID:
01359966
Message ID:
01359966
Views:
71
This is a bit long but....

I have a stand-alone SQLDataAccess class which contains generic methods for calling into MS Sql. It is generic enough so that I can use it in most of my apps.

In my app have an AppDataAccess class for handling data access within my app. It is simply a wrapper for calls to the SQLDataAccess and contains specific methods for the stored procedures I will be calling.

My SQLDataAccess has a method called 'ExecuteQueryProc' which takes as a parameter a collection class which holds instances of a Params class I wrote which simply mirror SqlParameters.

So in AppDataAccess I create as many Param classes as I need, set their parameters, then add them to the Params collection class, which I then pass this to ExecuteQueryProc in SQLDataAccess :
// SQLDataAccess. ExecuteQueryProc
public DataSet ExecuteQueryProc(ProcedureParams oParams)
{
DataSet oDataSet = new DataSet();

SqlConnection oConn = GetConnection(true);

if (oConn != null)
{
    SqlCommand oCommand = new SqlCommand(oParams.sProcedureName, oConn);
    oCommand.CommandType = CommandType.StoredProcedure;

    foreach (Param oColParam in oParams.Params)
    {
        SqlParameter oParam = new SqlParameter();

        oParam.DbType = DbType.Int32;
        oParam.Direction = ParameterDirection.Input;
        oParam.ParameterName = oColParam.sParameterName;
        oParam.SourceColumn = oColParam.sSrcColName;
        oParam.SqlDbType = SqlDbType.Int;
        oParam.Value = oColParam.Value;

        oCommand.Parameters.Add(oParam);

        oParam = null;
    }

    SqlDataAdapter oAdapter = new SqlDataAdapter();
    oAdapter.SelectCommand = oCommand;
    oAdapter.Fill(oDataSet);

    return oDataSet;
}
return oDataSet;
Ok, here's the problem. If I code each param individually using native ADO code, I get a data set back. If I use this code above, I get no records. I have walked it through a few times and I cannot see what the problem is. The data being set on the oParam object all appear to be ok.

Anyone wanna take a stab it this?
Everything makes sense in someone's mind
public class SystemCrasher :ICrashable
In addition, an integer field is not for irrational people
Next
Reply
Map
View

Click here to load this message in the networking platform