在vs2008中调试的时候没问题的
配置到IIS时,一开始可以访问
点击几个链接之后就出现错误
网上找了很多资料 有说数据库没关闭造成的
可是我基本上都关闭了啊 求各位帮忙看看代码
还有说是文件访问权限的问题
数据库是access 加过everyone的权限了
异常详细信息: System.Data.OleDb.OleDbException: 未指定的错误源错误:
行 23: {
行 24: this.con = new OleDbConnection(this.conStr);
行 25: this.con.Open();
行 26: }
行 27: private void close()
源文件: d:\Backup\代码\kyc\App_Code\DataBase.cs 行: 25 using System;
using System.Data;
using System.Configuration;
using System.Data.OleDb;
using System.Web;
using System.Collections;
using System.Text.RegularExpressions;namespace DataBaseLayer
{
public class DataBase : System.Web.UI.Page
{ public OleDbCommand com;
public OleDbConnection con;
private string conStr = "";
private OleDbDataReader dr;
public DataBase()
{
this.conStr = "provider=Microsoft.jet.OLEDB.4.0;data Source=" + HttpContext.Current.Server.MapPath("~/App_Data/kyc.mdb");
}
private void open()
{
this.con = new OleDbConnection(this.conStr);
this.con.Open();
}
private void close()
{
this.con.Close();
this.con.Dispose();
}
public int Insert(string str)
{
this.open();
OleDbCommand cmd = new OleDbCommand(str, this.con);
return cmd.ExecuteNonQuery();
this.close();
}
public int Delete(string str)
{
this.open();
this.com = new OleDbCommand(str, this.con);
return com.ExecuteNonQuery();
this.close();
}
public int Update(string str)
{
this.open();
OleDbCommand cmd = new OleDbCommand(str, this.con);
return cmd.ExecuteNonQuery();
this.close();
}
public string EcuteScalar(string str)
{
this.open();
OleDbCommand cmd = new OleDbCommand(str, this.con);
return cmd.ExecuteScalar().ToString();
this.close();
}
public OleDbDataReader getDataReader(string str)
{
this.open();
OleDbCommand cmd = new OleDbCommand(str, this.con);
return cmd.ExecuteReader(CommandBehavior.CloseConnection);
}
public OleDbDataAdapter getDataAdapter(string str)
{
open();
OleDbDataAdapter da = new OleDbDataAdapter(str, con);
return da;
this.close();
}
public DataSet getDataSet(string str)
{
DataSet ds = new DataSet();
try
{
open();
OleDbDataAdapter oda = new OleDbDataAdapter(str, con);
ds = new DataSet();
oda.Fill(ds);
}
catch
{
return null;
}
finally
{
this.close();
}
return ds;
}
}
配置到IIS时,一开始可以访问
点击几个链接之后就出现错误
网上找了很多资料 有说数据库没关闭造成的
可是我基本上都关闭了啊 求各位帮忙看看代码
还有说是文件访问权限的问题
数据库是access 加过everyone的权限了
异常详细信息: System.Data.OleDb.OleDbException: 未指定的错误源错误:
行 23: {
行 24: this.con = new OleDbConnection(this.conStr);
行 25: this.con.Open();
行 26: }
行 27: private void close()
源文件: d:\Backup\代码\kyc\App_Code\DataBase.cs 行: 25 using System;
using System.Data;
using System.Configuration;
using System.Data.OleDb;
using System.Web;
using System.Collections;
using System.Text.RegularExpressions;namespace DataBaseLayer
{
public class DataBase : System.Web.UI.Page
{ public OleDbCommand com;
public OleDbConnection con;
private string conStr = "";
private OleDbDataReader dr;
public DataBase()
{
this.conStr = "provider=Microsoft.jet.OLEDB.4.0;data Source=" + HttpContext.Current.Server.MapPath("~/App_Data/kyc.mdb");
}
private void open()
{
this.con = new OleDbConnection(this.conStr);
this.con.Open();
}
private void close()
{
this.con.Close();
this.con.Dispose();
}
public int Insert(string str)
{
this.open();
OleDbCommand cmd = new OleDbCommand(str, this.con);
return cmd.ExecuteNonQuery();
this.close();
}
public int Delete(string str)
{
this.open();
this.com = new OleDbCommand(str, this.con);
return com.ExecuteNonQuery();
this.close();
}
public int Update(string str)
{
this.open();
OleDbCommand cmd = new OleDbCommand(str, this.con);
return cmd.ExecuteNonQuery();
this.close();
}
public string EcuteScalar(string str)
{
this.open();
OleDbCommand cmd = new OleDbCommand(str, this.con);
return cmd.ExecuteScalar().ToString();
this.close();
}
public OleDbDataReader getDataReader(string str)
{
this.open();
OleDbCommand cmd = new OleDbCommand(str, this.con);
return cmd.ExecuteReader(CommandBehavior.CloseConnection);
}
public OleDbDataAdapter getDataAdapter(string str)
{
open();
OleDbDataAdapter da = new OleDbDataAdapter(str, con);
return da;
this.close();
}
public DataSet getDataSet(string str)
{
DataSet ds = new DataSet();
try
{
open();
OleDbDataAdapter oda = new OleDbDataAdapter(str, con);
ds = new DataSet();
oda.Fill(ds);
}
catch
{
return null;
}
finally
{
this.close();
}
return ds;
}
}
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货