Cybercrux

Everything is achievable through technology

DAL SP Common

public static DataTable QueryStoreprocedure(string ProcedureName, string InputParameters, params string[] values)
{
SqlCommand cmd = new SqlCommand(ProcedureName, CONDB);
cmd.CommandType = CommandType.StoredProcedure;
string[] fieldNames = InputParameters.Split(‘,’);
if (fieldNames.Length != values.Length)
throw new Exception(“DataAccess : Field names and values not matching…”);

for (int i = 0; i < values.Length; i++)
{
string Para = fieldNames[i].ToString().Trim();
string val = values[i].ToString().Trim();
cmd.Parameters.AddWithValue(Para, val);
}
DataTable DT = new DataTable();
ADPTR = new SqlDataAdapter(cmd);
ADPTR.Fill(DT);
return DT;
}

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s