I have the following code that executes an sql stored procedure and I pass a customer name and customer contact to the procedure to use to create a new record in a table. When I execute the stored procedure in sql it inputs the customer and contact in the new record but when I use the following code it creates a new record but the customer and contact are blank. Can anyone see what I have done wrong. Here is my code. Thanks in advance.
private void copyestBN_Click(object sender, EventArgs e)
{
{
int estno;
char customer;
char contact;
char.TryParse(customercopyCB.Text, out customer);
char.TryParse(newcontactTB.Text, out contact);
int.TryParse(estimatenocopyCB.Text, out estno);
{
SqlConnection conn = new SqlConnection("Data Source=server1;Initial Catalog=estimator;Integrated Security=True");
SqlCommand cmd = new SqlCommand("copyestimate", conn);
cmd.CommandType = CommandType.StoredProcedure;
cmd.Parameters.AddWithValue("@estnum", estno);
cmd.Parameters.AddWithValue("@customer", customer);
cmd.Parameters.AddWithValue("@contact", contact);
cmd.Parameters.AddWithValue("@newestnum", SqlDbType.Int).Direction = ParameterDirection.Output;
try
{
conn.Open();
cmd.ExecuteNonQuery();
newestLB.Items.Add(Convert.ToString(cmd.Parameters["@newestnum"].Value.ToString()));
}
catch (SqlException err)
{
MessageBox.Show(err.Message);
}
finally
{
if (conn.State == ConnectionState.Open)
conn.Close();
conn.Dispose();
}
}
}
}