C#如何将textbox中的内容写入ACCESS数据库。求完整代码。给大神跪了
2个回答
展开全部
OledbConnection myconn = new OledbConnection(“Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & server.mappath("tushu.mdb") & ";Persist Security Info=False”);
myconn.Open();
string strsql = "insert into table values('"+textBox1.Text+"')";
OledbCommand cmd = new OledbCommand(strsql,myconn);
cmd.ExecuteNonQuery();
myconn.Close();
//最后可以提示一下
MessageBox.Show("success");
myconn.Open();
string strsql = "insert into table values('"+textBox1.Text+"')";
OledbCommand cmd = new OledbCommand(strsql,myconn);
cmd.ExecuteNonQuery();
myconn.Close();
//最后可以提示一下
MessageBox.Show("success");
追问
大神你看我的sql语句有没有问题
string strtx1=.textBox1.text
string strtx2=.textBox2.text
inset into RegionCode(Code,Name)values('"+strtxtt1+"','"+strtxt2+'');
引用巨蟹囧rz小朋友的回答:
OledbConnection myconn = new OledbConnection(“Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & server.mappath("tushu.mdb") & ";Persist Security Info=False”);
myconn.Open();
string strsql = "insert into table values('"+textBox1.Text+"')";
OledbCommand cmd = new OledbCommand(strsql,myconn);
cmd.ExecuteNonQuery();
myconn.Close();
//最后可以提示一下
MessageBox.Show("success");
OledbConnection myconn = new OledbConnection(“Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & server.mappath("tushu.mdb") & ";Persist Security Info=False”);
myconn.Open();
string strsql = "insert into table values('"+textBox1.Text+"')";
OledbCommand cmd = new OledbCommand(strsql,myconn);
cmd.ExecuteNonQuery();
myconn.Close();
//最后可以提示一下
MessageBox.Show("success");
展开全部
"inset into RegionCode(Code,Name) values('"+strtxtt1+"','"+strtxt2+"')";
本回答被网友采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询