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 有兄弟姐妹会用word插图功能制作类似citespace的图片吗?
  • ¥200 uniapp长期运行卡死问题解决
  • ¥15 请教:如何用postman调用本地虚拟机区块链接上的合约?
  • ¥15 为什么使用javacv转封装rtsp为rtmp时出现如下问题:[h264 @ 000000004faf7500]no frame?
  • ¥15 乘性高斯噪声在深度学习网络中的应用
  • ¥15 关于docker部署flink集成hadoop的yarn,请教个问题 flink启动yarn-session.sh连不上hadoop,这个整了好几天一直不行,求帮忙看一下怎么解决
  • ¥15 深度学习根据CNN网络模型,搭建BP模型并训练MNIST数据集
  • ¥15 C++ 头文件/宏冲突问题解决
  • ¥15 用comsol模拟大气湍流通过底部加热(温度不同)的腔体
  • ¥50 安卓adb backup备份子用户应用数据失败