System.ArgumentException: 不支持关键字: “provider”
错误信息
System.ArgumentException: 不支持关键字: “provider”
行 314: public static DataTable GetDataTable(string strSQL)
行 315: {
行 316: SqlConnection Conn = new SqlConnection(strConn);
行 317: // DataTable datatable=new DataTable();
行 318: try
原码
-------------------------------------
using System;
using System.Configuration;
using System.Data.SqlClient;
using System.Data.OleDb;
using System.Data;
using System.Collections;
using System.ComponentModel;
using System.Drawing;
using System.Web;
using System.Web.SessionState;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.HtmlControls;
using System.IO;
namespace Rose.DataClass
{ public class CDataBase
{
static string dppath =HttpContext.Current.Request.PhysicalApplicationPath + "\\ " + ConfigurationSettings.AppSettings[ "Sql_Conn "];
protected static string strConn = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source= " +dppath+ "; ";
protected static string strSQL;
protected static SqlConnection Conn;
protected string strMessage;
protected static SqlConnection ConnDr;
public CDataBase()
{
//
// TODO: 在此处添加构造函数逻辑
//
}
public string Message
{
get
{
return strMessage;
}
set
{
strMessage = value;
}
}
public static DataTable GetDataTable(string strSQL)
{
SqlConnection Conn = new SqlConnection(strConn);
// DataTable datatable=new DataTable();
try
{
Conn.Open();
SqlDataAdapter sda = new SqlDataAdapter(strSQL,Conn);
DataTable dt = new DataTable( "dt ");
sda.Fill(dt);
return dt;
}
catch(
System.Data.SqlClient.SqlException e)
{
throw new Exception(e.Message);
}
finally
{
Conn.Close();
}
}
------解决方案--------------------System.ArgumentException: 不支持关键字: “provider”
===================================================
不是你提供的protected static string strConn = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source= " +dppath+ "; ";这一行
它找到的错误是小写的(大小写不关键,但你的代码那里还有小写的provider)
------解决方案--------------------改用 OLEDB
------解决方案--------------------Data Source= 'fdc.mdb ';Jet OLEDB:database password=123; Provider= 'Microsoft.Jet.OLEDB.4.0 ';User ID=Admin
连接字符串