Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Method Design Question
Message
General information
Forum:
ASP.NET
Category:
Coding, syntax and commands
Miscellaneous
Thread ID:
01381477
Message ID:
01381487
Views:
31
You can simply add one extra parameter that will tell you what you're running. You can default it to SP and use an overload, so your other calls to this method will work as is.

>In my Data Class I have the ExecuteQuery method shown below. It's possible to pass as 'sCommand' either a SELECT command or a stored procedure name.
>
>The question is, how do I tell the method that 'sCommand contains a sproc vs. a transaction statement?
>
>
>public DataSet ExecuteQuery(string sCommand, string sTableName, SqlParameter[] colParameters)
>{
>    SqlCommand oCommand = _GetCommand(sCommand);
>    SqlConnection oConn = _GetConnection(false);
>
>    if (sTableName == "")
>    {
>        sTableName = "";
>    }
>
>    if (colParameters != null)
>    {
>        oCommand.Parameters.Clear();
>        oCommand.Parameters.AddRange(colParameters);
>        oCommand.CommandType = CommandType.StoredProcedure;
>    }
>
>    
>    DataSet oDataSet = new DataSet();
>    _oAdapter = new SqlDataAdapter(sCommand, oConn);
>
>    SqlCommandBuilder oBuilder = new SqlCommandBuilder(_oAdapter);
>
>    _oAdapter.SelectCommand = oCommand;
>
>    try
>    {
>        _oAdapter.Fill(oDataSet, sTableName);
>
>    }
>
>    return oDataSet;
>}
>
>
If it's not broken, fix it until it is.


My Blog
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform