Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Help with passing multiple parameters to a stored procedure

Status
Not open for further replies.

johnsun1976

Programmer
Jan 28, 2002
34
CA
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();
}
 
The code seems to be correct. Probably your error is in the Stored Procedure, and the error remains on your SQL Server.
hth
 
Yeah, the code looks good. I'd check elsewhere. Maybe execute permissions for the SP.

Chip H.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top