toorkaman
سه شنبه 06 مهر 1389, 14:55 عصر
سلام ، لطف می کنید ایراد این چند خط کد را به من بگید ،می خواهم اطلاعات داخل comboboxها وtextboxها دربانک ثبت شود،objadapter.InsertCommand = new SqlCommand();
objadapter.InsertCommand.Connection = objconn;
objadapter.InsertCommand.CommandText = "insert into daneshjo(univer,reshte,maghtah,nezam,nimsal,men,wo man,...) values(@field1,@field2,@field3,@field4,@field5,@fi eld6,@field7...)";
objadapter.InsertCommand.Parameters.AddWithValue("@field1", comboBox6.Text.Trim());
objadapter.InsertCommand.Parameters.AddWithValue("@field2", comboBox1.Text.Trim());
objadapter.InsertCommand.Parameters.AddWithValue("@field3", comboBox5.Text.Trim());
objadapter.InsertCommand.Parameters.AddWithValue("@field4", comboBox4.Text.Trim());
objadapter.InsertCommand.Parameters.AddWithValue("@field5", comboBox7.Text.Trim());
objadapter.InsertCommand.Parameters.AddWithValue("@field6", textBox1.Text.Trim());
objadapter.InsertCommand.Parameters.AddWithValue("@field7", textBox1.Text.Trim());
objconn.Open();
objadapter.InsertCommand.ExecuteNonQuery();این خط را ارورsyntaxمیگیره
objconn.Close();
objadapter.InsertCommand.Connection = objconn;
objadapter.InsertCommand.CommandText = "insert into daneshjo(univer,reshte,maghtah,nezam,nimsal,men,wo man,...) values(@field1,@field2,@field3,@field4,@field5,@fi eld6,@field7...)";
objadapter.InsertCommand.Parameters.AddWithValue("@field1", comboBox6.Text.Trim());
objadapter.InsertCommand.Parameters.AddWithValue("@field2", comboBox1.Text.Trim());
objadapter.InsertCommand.Parameters.AddWithValue("@field3", comboBox5.Text.Trim());
objadapter.InsertCommand.Parameters.AddWithValue("@field4", comboBox4.Text.Trim());
objadapter.InsertCommand.Parameters.AddWithValue("@field5", comboBox7.Text.Trim());
objadapter.InsertCommand.Parameters.AddWithValue("@field6", textBox1.Text.Trim());
objadapter.InsertCommand.Parameters.AddWithValue("@field7", textBox1.Text.Trim());
objconn.Open();
objadapter.InsertCommand.ExecuteNonQuery();این خط را ارورsyntaxمیگیره
objconn.Close();