错误信息
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”行 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();
}
}
解决方案 »
- google未定义,javascript报错,有谁遇到过类似问题啊?~~
- 请教TreeView的布局问题
- 新手请教
- 关于decimal小数位数显示的问题
- 正则表达式:只允许输入4-15位任意字符
- 为什么老是出错, 说没有权限打开Access文件
- 水晶报表如何设置分页以及每一页现实的记录条数?
- 请问,怎样在.net的webform中引入windows mediaplayer?
- 在Linux下怎么写asp.net程序?
- window server 2003 为什么不能编译ASP程序?
- CrystalReportViewer1:未知的服务器标记“cr:CrystalReportViewer”
- ★100分求C#打印当前页面的例子。
===================================================
不是你提供的protected static string strConn ="Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" +dppath+";";这一行它找到的错误是小写的(大小写不关键,但你的代码那里还有小写的provider)
我改了成
protected static string strConn="provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + System.Web.HttpContext.Current.Server.MapPath(System.Configuration.ConfigurationSettings.AppSettings["ConnectionString"]);还是一样的错误
在 ConnectionString 中未指定 OLE DB 提供程序。示例为:“Provider=SQLOLEDB;”。
说明: 执行当前 Web 请求期间,出现未处理的异常。请检查堆栈跟踪信息,以了解有关该错误以及代码中导致错误的出处的详细信息。 异常详细信息: System.ArgumentException: 在 ConnectionString 中未指定 OLE DB 提供程序。示例为:“Provider=SQLOLEDB;”。源错误:
行 313: public static DataTable GetDataTable(string strSQL)
行 314: {
行 315: OleDbConnection Conn = new OleDbConnection(strConn);
行 316: // OleDbConnection connection = new OleDbConnection();
行 317:
连接字符串
{
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();
}
}
》》》
public static DataTable GetDataTable(string strSQL)
{
OleDbConnection Conn = new OleDbConnection(strConn);
//DataTable datatable=new DataTable();
try
{
Conn.Open();
OleDbDataAdapter sda = new OleDbDataAdapter(strSQL,Conn);
DataTable dt = new DataTable("dt");
sda.Fill(dt);
return dt;
}
catch(System.Data.OleDbClient.OleDbException e)
{
throw new Exception(e.Message);
}
finally
{
Conn.Close();
}
}
Good Luck!
现在又有问题了!异常详细信息: System.Exception: 找不到可安装的 ISAM。我用的是:
protected static string strConn="Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + System.Web.HttpContext.Current.Server.MapPath(System.Configuration.ConfigurationSettings.AppSettings["ConnectionString"]);连接的