I am getting this error
Invalid column name Id.
What is wrong?
private void btnInsert_Click(object sender, EventArgs e)
{
connection.Open();
try
{
string query2 = "INSERT INTO Suppliers (SupName) OUTPUT
Inserted.Id VALUES (@SupName)";
SqlCommand cmd2 = new SqlCommand(query2, connection);
cmd2.Parameters.AddWithValue("@SupName", txtCname.Text);
int supID = (int)cmd2.ExecuteScalar();
//cmd2.Parameters.Clear();
string query3 = "INSERT INTO SupplierContacts (SupConAddress,
SupConCity, AffiliationId, SupplierId)
VALUES (@SupConAddress, @SupConCity,
@AffiliationId, @SupplierId)";
SqlCommand cmd3 = new SqlCommand(query3, connection);
cmd3.Parameters.AddWithValue("@SupConAddress", txtCaddress.Text);
cmd3.Parameters.AddWithValue("@SupConCity", txtCcity.Text);
cmd3.Parameters.AddWithValue("@AffiliationId", aff.AffilitationId);
cmd3.Parameters.AddWithValue("@SupplierId", supID);
// cmd3.Parameters.Clear();
MessageBox.Show("Data Inserted");
}
catch(SqlException ex)
{
MessageBox.Show(ex.Message);
}
connection.Close();
}