【发布时间】:2013-12-03 09:41:56
【问题描述】:
protected void Button1_Click1(object sender, EventArgs e)
{
try
{
OleDbConnection con = new OleDbConnection("Provider=Microsoft.ACE.OLEDB.12.0;Data Source=D:/WEB/App_Data/mydata.accdb");
OleDbCommand com = new OleDbCommand("insert into player_reg (p_name,f_name,dob,pob,sex,marital,nation,address,address,state,mob,email,course,college,y_year,sports,voter) values ('" + TextBox1.Text + "', '" + TextBox2.Text + "','" + TextBox3.Text + "', '" + TextBox4.Text + "','" + TextBox5.Text + "', '" + TextBox6.Text + "','" + TextBox7.Text + "', '" + TextBox8.Text + "','" + TextBox9.Text+ "', '" + TextBox10.Text + "','" + TextBox11.Text + "', '" + TextBox12.Text+ "','" + TextBox13.Text+ "', '" + TextBox14.Text + "''" + TextBox15.Text + "', '" + TextBox16.Text + "')", con);
con.Open();
com.CommandType = CommandType.Text;
com.ExecuteNonQuery();
Response.Write("values inserted successfully");
con.Close();
}
catch (Exception ex)
{
Response.Write(ex.ToString());
}
}
【问题讨论】: