Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
C# ADO Executing Stored Procedure Problem
Message
General information
Forum:
ASP.NET
Category:
Coding, syntax and commands
Title:
C# ADO Executing Stored Procedure Problem
Miscellaneous
Thread ID:
01374697
Message ID:
01374697
Views:
64
I posted something similar a while back, and I still cant get this to work.

I wrote a data access class. It has an ExecuteStoredProc method which accepts a class that contains all the necessaru info, such as the name of the sproc and a collection of params to pass to SQL.

I'm getting the exception "@Parameter1 is not a parameter for procedure bm_GetAppOverview."

I run it like this. As you can see, I specified the parameter column name as "AppKey". Anyone know what's happening?
static void Main(string[] args)
{
    DataAccess oDataAccess = new DataAccess();

    oDataAccess.Provider = DataAccess.ProviderType.SQL;
    oDataAccess.ConnectionString = sConnString;


    // Paramaters collection object
    DataAccess.ProcedureParams oParams = new DataAccess.ProcedureParams();
    oParams.sProcedureName = "bm_GetAppOverview";

    // Create param objects and add to the collection
    DataAccess.Param oAppKey = new DataAccess.Param();
    oAppKey.Direction = System.Data.ParameterDirection.Input;
    oAppKey.iSize = 0;
    oAppKey.sSrcColName = "AppKey";
    oAppKey.value = 0;

    oParams.AddParam(oAppKey);

    // Call into the data access class & run the sproc
    DataSet oData = oDataAccess.ExecuteStoredProc(oParams);
}
Here's the ExecuteStoredProc code:
public DataSet ExecuteStoredProc(ProcedureParams oParams)
{
    DataSet oDataSet = new DataSet();;

    IDbCommand oCommand = _GetCommand(oParams.sProcedureName);

    if (oCommand != null)
    {
        oCommand.CommandType = CommandType.StoredProcedure;

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

            oParam.DbType = oColParam.Type;
            oParam.Direction = oColParam.Direction;
            oParam.SourceColumn = oColParam.sSrcColName;
            oParam.Size = oColParam.iSize;
            oParam.Value = oColParam.value;

            oCommand.Parameters.Add(oParam);
        }

        IDbDataAdapter oAdapter = _GetDataAdapter(oParams.sProcedureName);

        if (oAdapter != null)
        {

            oAdapter.SelectCommand = oCommand;

            try
            {
                oAdapter.Fill(oDataSet);

            }
            catch (SqlException e)
            {
                // Removed for brevity
            }
        }
    }
    return oDataSet;
I know the _GetCommand and _GetDataAdapter methods work because they are already in use elsewhere.
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