johnsun1976
Programmer
Hi.. I'm having problems trying to pass more than one parameters to a store procedure.. This is code I tried.. I know the store procedure work.. Can anyone give me some insight to what I'm doing wrong? The code compiles and run without errors..
Thanks
John
private void cmdTaxSave_Click(object sender, System.EventArgs e)
{
SqlCommand cmd = new SqlCommand("InsertEditTax", conn);
cmd.CommandType = System.Data.CommandType.StoredProcedure;
// Parameters
SqlParameter paraTaxDesc1 = new SqlParameter("@TaxDesc1", System.Data.SqlDbType.VarChar ,50);
paraTaxDesc1.Value = "'" + txtTaxDesc1.Text + "'";
cmd.Parameters.Add(paraTaxDesc1);
SqlParameter paraTaxRate1= new SqlParameter("@TaxRate1", System.Data.SqlDbType.Float);
paraTaxRate1.Value = Convert.ToDecimal(txtTaxRate1.Text);
cmd.Parameters.Add(paraTaxRate1);
-- Goes on for 4 more parameters.
try
{
conn.Open();
}
catch(Exception oException)
{
throw oException;
}
finally
{
conn.Close();
}
Thanks
John
private void cmdTaxSave_Click(object sender, System.EventArgs e)
{
SqlCommand cmd = new SqlCommand("InsertEditTax", conn);
cmd.CommandType = System.Data.CommandType.StoredProcedure;
// Parameters
SqlParameter paraTaxDesc1 = new SqlParameter("@TaxDesc1", System.Data.SqlDbType.VarChar ,50);
paraTaxDesc1.Value = "'" + txtTaxDesc1.Text + "'";
cmd.Parameters.Add(paraTaxDesc1);
SqlParameter paraTaxRate1= new SqlParameter("@TaxRate1", System.Data.SqlDbType.Float);
paraTaxRate1.Value = Convert.ToDecimal(txtTaxRate1.Text);
cmd.Parameters.Add(paraTaxRate1);
-- Goes on for 4 more parameters.
try
{
conn.Open();
}
catch(Exception oException)
{
throw oException;
}
finally
{
conn.Close();
}