C#里面添加数据库信息,添加不进去Access数据库代码如下大佬求救啊?
protectedvoidButton1_Click(objectsender,EventArgse){if(Page.IsValid){stringoleCon="Pr...
protected void Button1_Click(object sender, EventArgs e)
{
if (Page.IsValid)
{
string oleCon = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=E:\\360Downloads\\Music.accdb";
OleDbConnection conn = new OleDbConnection(oleCon);
conn.Open();
String Access = "insert into user(username,password) values=('"+ this.TextBox1 .Text .Trim()+ "','" + this.TextBox2 .Text .Trim()+ "')";
OleDbCommand cmd = new OleDbCommand(Access, conn); 展开
{
if (Page.IsValid)
{
string oleCon = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=E:\\360Downloads\\Music.accdb";
OleDbConnection conn = new OleDbConnection(oleCon);
conn.Open();
String Access = "insert into user(username,password) values=('"+ this.TextBox1 .Text .Trim()+ "','" + this.TextBox2 .Text .Trim()+ "')";
OleDbCommand cmd = new OleDbCommand(Access, conn); 展开
2019-11-16
展开全部
有没有少这行代码 ,没有的话加在最后面
cmd.ExecuteNonQuery(); //执行命令
cmd.ExecuteNonQuery(); //执行命令
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询