日期:2014-05-17 浏览次数:20515 次
protected void Button1_Click(object sender, EventArgs e)
{
string s = ConfigurationManager.ConnectionStrings["db2"].ToString();
OleDbConnection cn = new OleDbConnection(s);
cn.Open();
string sql = "insert into student1(name,pd,email,text) values('" + this.name.Text + "','" + this.TextBox1.Text + "','" + this.TextBox3.Text + "','" + this.TextBox4.Text + "')";
string strInsert = " INSERT INTO student1 ( name,pd,email,text) VALUES ( ";
strInsert += name.Text + ", '";
strInsert += TextBox1.Text + "', '";
strInsert +=TextBox2.Text + "', ";
strInsert +=TextBox4.Text + ")";
OleDbCommand cm = new OleDbCommand(strInsert, cn);
cm.ExecuteNonQuery();//错误出现在这一步
cn.Close();
}
string strInsert = " INSERT INTO student1 ( name,pd,email,text) VALUES ( ";
strInsert += name.Text + ", '";
strInsert += TextBox1.Text + "', '";
strInsert +=TextBox2.Text + "', ";
strInsert +=TextBox4.Text + ")";