建好应用程序,运行程序在添加数据库时,提示列名错误是哪里出了问题啊?
private void button1_Click(object sender, System.EventArgs e)
{
try
{
if(this.textBox1.Text!="" &this.textBox2.Text!="" &this.textBox3.Text!="" &this.textBox4.Text!="" &this.textBox5.Text!="" &this.textBox6.Text!="" &this.textBox7.Text!="" &this.textBox8.Text!="" &this.textBox9.Text!="")
{
SqlConnection thisConnection=new SqlConnection(@"Data Source=(local);Integrated Security=SSPI;"+"Initial Catalog=student");
string insert= " INSERT INTO 成绩 (学号,姓名,性别,出生日期,籍贯,政治面貌,民族,毕业时间,就业情况,就业单位) VALUES ('" ;
insert += this.textBox1.Text + "', '";
insert += this.textBox2.Text + "', '";
insert += this.textBox3.Text + "', '";
insert += this.textBox4.Text + "', '";
insert += this.textBox5.Text + "', '";
insert += this.textBox6.Text + "', '";
insert += this.textBox7.Text + "', '";
insert += this.textBox8.Text + "', '";
insert += this.textBox9.Text + "', '";
insert += this.textBox10.Text + "') ";
//初始化OleDbCommand
SqlCommand comm=new SqlCommand();
comm.CommandText=insert;
comm.Connection=thisConnection;
//打开数据库连接
thisConnection.Open();
//执行添加记录的语句
comm.ExecuteNonQuery();
//关闭记录
thisConnection.Close();
}
else
MessageBox.Show("*号必须添完整","提示",MessageBoxButtons.OK,MessageBoxIcon.Information);
}
catch(Exception ed)
{
MessageBox.Show("添加记录发生错误:"+ed.Message,"提示",MessageBoxButtons.OK,MessageBoxIcon.Information);
}
}
代码有没有错啊,帮我看看吧,应该不是数据库问题吧,我在查询的时候可以啊
添加的时候性别出了问题