这段代码写入不了。提示“MySql.ExecuteNonQuery();”错误,我检查过了,句子输入对的。不知道错在哪里?
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();
}还有请问如何按行(mdb)导入LIST。先行谢谢各位有心人士了。accessc#mdb数据库mdb写入
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();
}还有请问如何按行(mdb)导入LIST。先行谢谢各位有心人士了。accessc#mdb数据库mdb写入
解决方案 »
- 关于程序安装打包。在线等.....
- 报错 '无法显示反汇编 表达式还没有翻译为本机代码'
- 问你一个逻辑上的问题:
- 如何实现新弹出小窗口后,父窗口冻结,不可编辑,新窗口选择完成确定后,数据传至父窗体.
- 如何用C# 实现 ACCESS 到 文本文件的相互转换
- 请问在access中可不可以保存word文档,如何存。
- 关于一个c#中的一个数据转换的问题
- C#windows media player如何解除文件占用问题?
- 泛型的接口能否转化为非泛型的对应接口? 编译不过啊
- 如何通过DefaultValue指定属性的枚举(enum)类型默认值,
- 如何获取当前word进程 并关闭
- 1到9999,中含有1的数字
While (dr.read())
{
//在这里加入,使用dr[0],dr[1].. dr[n]来读取一行的每一个元素
add...
}
OleDbCommand MySql = new OleDbCommand("INSERT INTO [user](names,pwd) values ('"+ textBox1.Text + "','" + textBox2.Text + "')", con);