R
Ravi Kumar12233
Guest
I have two winforms where form 1 is used to enter data from first seven fields and other forms is used to enter for last three fields , where i have the table stored in MSSQL server ,Now when i try to save the last three fields i am getting below " invalid column error , but actually it is present in my sql table , i am very new to C# , kindly help me :
Code for saving data in second form:
private void Btnrejsave_Click(object sender, EventArgs e)
{
SqlConnection con = new SqlConnection(cs);
SqlCommand cmd;
con.Open();
string s = "select * from RejReason where SpoolId = (@p4) insert into IP_Spools(RejectReason1,RejectReason2,RejectReason3) values(@p1,@p2,@p3)";
cmd = new SqlCommand(s, con);
cmd.Parameters.AddWithValue("@p1", rejectReason1ComboBox.Text);
cmd.Parameters.AddWithValue("@p2", rejectReason2ComboBox.Text);
cmd.Parameters.AddWithValue("@p3", rejectReason3ComboBox.Text);
cmd.Parameters.AddWithValue("@p4", IDtextbox.Text);
cmd.CommandType = CommandType.Text;
int i = cmd.ExecuteNonQuery();
con.Close();
}
And the error i am getting :
{"Invalid column name 'SpoolId'."}
but the server table has that column:
![2Obur.png 2Obur.png](https://www.computerhelp.forum/data/attachments/57/57818-b301575262386bf99ea5f1a40a18c3c3.jpg?hash=swFXUmI4a_)
![PwI4y.png PwI4y.png](https://www.computerhelp.forum/data/attachments/57/57819-1318e8237079aa829de1b1c3be03c974.jpg?hash=ExjoI3B5qo)
Continue reading...
Code for saving data in second form:
private void Btnrejsave_Click(object sender, EventArgs e)
{
SqlConnection con = new SqlConnection(cs);
SqlCommand cmd;
con.Open();
string s = "select * from RejReason where SpoolId = (@p4) insert into IP_Spools(RejectReason1,RejectReason2,RejectReason3) values(@p1,@p2,@p3)";
cmd = new SqlCommand(s, con);
cmd.Parameters.AddWithValue("@p1", rejectReason1ComboBox.Text);
cmd.Parameters.AddWithValue("@p2", rejectReason2ComboBox.Text);
cmd.Parameters.AddWithValue("@p3", rejectReason3ComboBox.Text);
cmd.Parameters.AddWithValue("@p4", IDtextbox.Text);
cmd.CommandType = CommandType.Text;
int i = cmd.ExecuteNonQuery();
con.Close();
}
And the error i am getting :
{"Invalid column name 'SpoolId'."}
but the server table has that column:
![2Obur.png 2Obur.png](https://www.computerhelp.forum/data/attachments/57/57818-b301575262386bf99ea5f1a40a18c3c3.jpg?hash=swFXUmI4a_)
![PwI4y.png PwI4y.png](https://www.computerhelp.forum/data/attachments/57/57819-1318e8237079aa829de1b1c3be03c974.jpg?hash=ExjoI3B5qo)
Continue reading...