asp.net萌新求大神来帮忙“System.Data.OleDb.OleDbException”类型的异常在 System.Data.dll 中发生
usingSystem;usingSystem.Collections.Generic;usingSystem.Data.SqlClient;usingSystem.Li...
using System;using System.Collections.Generic;using System.Data.SqlClient;using System.Linq;using System.Web;using System.Web.UI;using System.Web.UI.WebControls;using System.Data.OleDb;namespace SchoolFood{ public partial class zhuce : System.Web.UI.Page { protected void Page_Load(object sender, EventArgs e) { } protected void Button1_Click(object sender, EventArgs e) { string str_provider = "Provider=Microsoft.Jet.OLEDB.4.0; "; string str_source ="Data Source="+ MapPath("~/DB/Users.mdb"); string str_connection = str_provider + str_source; OleDbConnection cnn; OleDbCommand cmd; string str_sql = "INSERT INTO [T_Users] (user,pass) values ('"+TextUser.Text+"','"+TextPass.Text+"')"; cnn = new OleDbConnection(str_connection); cnn.Open(); cmd = new OleDbCommand(str_sql, cnn); cmd.ExecuteNonQuery();(这句出问题) cnn.Close(); Server.Transfer("Login.aspx"); } protected void Button2_Click(object sender, EventArgs e) { Server.Transfer("Login.aspx"); } }}错误提示:“System.Data.OleDb.OleDbException”类型的异常在 System.Data.dll 中发生,但未在用户代码中进行处理
我想大多数是字符串问题,但就是找不到,我贴下来好看一点 :
string str_provider = "Provider=Microsoft.Jet.OLEDB.4.0; ";
string str_source ="Data Source="+ MapPath("~/DB/Users.mdb");
string str_connection = str_provider + str_source;
string str_sql = "INSERT INTO [T_Users] (user,pass) values ('"+TextUser.Text+"','"+TextPass.Text+"')";(我用T_Users不加[ ]也是一样的) 展开
我想大多数是字符串问题,但就是找不到,我贴下来好看一点 :
string str_provider = "Provider=Microsoft.Jet.OLEDB.4.0; ";
string str_source ="Data Source="+ MapPath("~/DB/Users.mdb");
string str_connection = str_provider + str_source;
string str_sql = "INSERT INTO [T_Users] (user,pass) values ('"+TextUser.Text+"','"+TextPass.Text+"')";(我用T_Users不加[ ]也是一样的) 展开
1个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询