110,536
社区成员
发帖
与我相关
我的任务
分享
private void button1_Click(object sender, EventArgs e)
{
string reportPath = Application.StartupPath.Substring(0, Application.StartupPath.Substring(0, Application.StartupPath.LastIndexOf("\\")).LastIndexOf("\\"));
reportPath += @"\Date.mdb";
string ConStr = "Provider=Microsoft.ACE.OLEDB.12.0;Data source=" + reportPath;
//string strSQL = "INSERT INTO user (names,pwd) VALUES('" + textBox1.Text + " ',' " + textBox2.Text + "')";
//创建Connection 对象
OleDbConnection con = new OleDbConnection(ConStr);
//创建Command对象
OleDbCommand MySql = new OleDbCommand("INSERT INTO user(names,pwd) values ('"+ textBox1.Text + "','" + textBox2.Text + "')", con);
con.Open();
MySql.ExecuteNonQuery();
con.Close();
}