fyb1261369646 2017-11-05 09:42 采纳率: 0%
浏览 1602

asp.net(C#)注册页面输入的数据输入Access数据库

使用的工具是VS2010,Access2010
错误提示:在 ConnectionString 中未指定 OLE DB 提供程序。示例为:“Provider=SQLOLEDB;”
代码如下:

login.aspx.cs

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data.OleDb;
using System.Web.Configuration;

public partial class login : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{

}
protected void Button1_Click(object sender, EventArgs e)
{
    string user_name, user_pw, real_name, title, school, department, phone_number, email;
    user_name = UserText.Text.Replace("'", "''");
    user_pw = PassText.Text.Replace("'", "''");
    real_name = NameText.Text.Replace("'", "''");
    title = TitleText.Text.Replace("'", "''");
    school = SchoolText.Text.Replace("'", "''");
    department = DepartmentText.Text.Replace("'", "''");
    phone_number = PhoneText.Text.Replace("'", "''");
    email = EmailText.Text.Replace("'", "''");

    string strConn = WebConfigurationManager.ConnectionStrings["LocalSqlServer"].ConnectionString;
    OleDbConnection conn = new OleDbConnection(strConn);
    conn.Open();
    string sql = "insert into userinfo (user_name,user_pw,real_name,title,school,department,phone_number,email)values]('" + user_name + "','" + user_pw + "','" + real_name + "','" + title + "','" + school + "','" + department + "','" + phone_number + "','" + email + "')";
    OleDbCommand cmd = new OleDbCommand(sql,conn);
    cmd.ExecuteNonQuery();
    conn.Close();
}

private void CheckInput()
{
    throw new NotImplementedException();
}
protected void UserText_TextChanged(object sender, EventArgs e)
{

}

}


web.config






connectionString="Provider=Microsoft.Jet.OleDb.4.0;Data ;
Data source=D:\My Documents\Documents\Database3.accdb;
Persist Security Info=False;"/>


查了很多解决办法均失败,求大神指教

  • 写回答

1条回答 默认 最新

  • threenewbee 2017-11-05 09:47
    关注

    Provider=Microsoft.Jet.OleDb.4.0
    这个提供程序过时了,只能用于access 2003以前的版本,accdb是2007/10/13/16的格式,需要换ACE驱动。

    下载ace14驱动 http://www.microsoft.com/zh-cn/download/details.aspx?id=13255

    连接字符串换成 Microsoft.ACE.OLEDB.14.0

    评论

报告相同问题?

悬赏问题

  • ¥15 虚拟机打包apk出现错误
  • ¥30 最小化遗憾贪心算法上界
  • ¥15 用visual studi code完成html页面
  • ¥15 聚类分析或者python进行数据分析
  • ¥15 逻辑谓词和消解原理的运用
  • ¥15 三菱伺服电机按启动按钮有使能但不动作
  • ¥15 js,页面2返回页面1时定位进入的设备
  • ¥50 导入文件到网吧的电脑并且在重启之后不会被恢复
  • ¥15 (希望可以解决问题)ma和mb文件无法正常打开,打开后是空白,但是有正常内存占用,但可以在打开Maya应用程序后打开场景ma和mb格式。
  • ¥20 ML307A在使用AT命令连接EMQX平台的MQTT时被拒绝