Error Couldn't find stored procedure ""

  • Thread starter Thread starter engahmedbarbary
  • Start date Start date
E

engahmedbarbary

Guest
Problem

Error Couldn't find stored procedure ""

Details

I create stored procedure as

create proc spwahunits
as
select * from WAHUnits

and i under button of windows form i call it as below

private void btndisplay_Click(object sender, EventArgs e)
{
DataTable dt = new DataTable();
dt = DataAccess.ExecuteDataTablewithsp("spwahunits");
}

Inside Dataaccess Class i have function as below

public static DataTable ExecuteDataTablewithsp(string sql, DbParameter[] dbprmParameters = null)
{
return ExecuteDataTablesp2(sql, null, CommandType.StoredProcedure, dbprmParameters);
}
public static DataTable ExecuteDataTablesp2(string spsql, IDbConnection dbConnection, CommandType commandType, DbParameter[] @params = null)
{
if (spsql == "") return new DataTable();
DataSet ds = new DataSet();





#region Old Connection
lock (synObj)
{

spsql = AnalyizeBooleanFields(spsql);
cmd.CommandType = commandType;
cmd.Parameters.Clear();

if (@params != null)
{
for (int i = 0; i < @params.Length; i++)
{
cmd.Parameters.Add(@params);
}
}
if (dbConnection == null)
{
if (WithTransaction)
dbConnection = BeginTransaction();
else
dbConnection = InitializeConnection();
}
if (dbConnection.State != ConnectionState.Open) dbConnection.Open();
if (WithTransaction) cmd.Transaction = _transaction;
cmd.Connection = dbConnection;
IDbDataAdapter dbCurrentDataAdapter = InitializeDataAdapter();
dbCurrentDataAdapter.SelectCommand = cmd;
dbCurrentDataAdapter.Fill(ds);

if (!WithTransaction) dbConnection.Close();
}

return ds.Tables[0];

}

Continue reading...
 
Back
Top