| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 1456 人关注过本帖
标题:未指定的错误
取消只看楼主 加入收藏
jasoft
Rank: 1
来 自:北京 东城
等 级:新手上路
帖 子:32
专家分:0
注 册:2007-7-19
收藏
 问题点数:0 回复次数:0 
未指定的错误
页面出现这个错误,刷新后就会正常,再刷新又会出错!
错误源代码为:


“/caipiao”应用程序中的服务器错误。
--------------------------------------------------------------------------------

未指定的错误
说明: 执行当前 Web 请求期间,出现未处理的异常。请检查堆栈跟踪信息,以了解有关该错误以及代码中导致错误的出处的详细信息。

异常详细信息: System.Data.OleDb.OleDbException: 未指定的错误

源错误:


行 28:         {
行 29:
行 30:             conn.Open();
行 31:
行 32:         }
 

源文件: f:\吕立辉\项目\caipiao\App_Code\DB.cs    行: 30

堆栈跟踪:


[OleDbException (0x80004005): 未指定的错误]
   System.Data.OleDb.OleDbConnectionInternal..ctor(OleDbConnectionString constr, OleDbConnection connection) +1131233
   System.Data.OleDb.OleDbConnectionFactory.CreateConnection(DbConnectionOptions options, Object poolGroupProviderInfo, DbConnectionPool pool, DbConnection owningObject) +53
   System.Data.ProviderBase.DbConnectionFactory.CreateNonPooledConnection(DbConnection owningConnection, DbConnectionPoolGroup poolGroup) +27
   System.Data.ProviderBase.DbConnectionFactory.GetConnection(DbConnection owningConnection) +47
   System.Data.ProviderBase.DbConnectionClosed.OpenConnection(DbConnection outerConnection, DbConnectionFactory connectionFactory) +105
   System.Data.OleDb.OleDbConnection.Open() +37
   DB.Getconn() in f:\吕立辉\项目\caipiao\App_Code\DB.cs:30
   DB.closeConnection() in f:\吕立辉\项目\caipiao\App_Code\DB.cs:42
   DB.binddatalist(String sql, DataList dl) in f:\吕立辉\项目\caipiao\App_Code\DB.cs:297
   friend_fc.bang() in f:\吕立辉\项目\caipiao\friend\fc.ascx.cs:25
   friend_fc.Page_Load(Object sender, EventArgs e) in f:\吕立辉\项目\caipiao\friend\fc.ascx.cs:18
   System.Web.Util.CalliHelper.EventArgFunctionCaller(IntPtr fp, Object o, Object t, EventArgs e) +15
   System.Web.Util.CalliEventHandlerDelegateProxy.Callback(Object sender, EventArgs e) +33
   System.Web.UI.Control.OnLoad(EventArgs e) +99
   System.Web.UI.Control.LoadRecursive() +47
   System.Web.UI.Control.LoadRecursive() +131
   System.Web.UI.Control.LoadRecursive() +131
   System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +1436

 


另附链接数据库的类,高手帮看看是哪里出的错误啊!急哇!

public class DB
{
    System.Data.OleDb.OleDbConnection conn;
    public DB()
    {
        //
        // TODO: 在此处添加构造函数逻辑
        //
    }
    public static OleDbConnection Getconn()
    {
        OleDbConnection conn = new OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data source=" + System.Web.HttpContext.Current.Server.MapPath(ConfigurationManager.AppSettings["ConnectionString"].ToString()));
        if (conn.State.Equals(ConnectionState.Closed))
        {

            conn.Open();

        }
        return conn;
   
    }
    //=================================================
    //功能描述:关闭数据库
    //时间:2007.11.10
    //=================================================
    private static void closeConnection()
    {
        OleDbConnection conn = DB.Getconn();
        OleDbCommand cmd = new OleDbCommand();
        if (conn.State == ConnectionState.Open)
        {
            conn.Close();
            conn.Dispose();
            cmd.Dispose();
        }
    }
    //=================================================
    //功能描述:执行SQL语句
    //输入参数:sql,查询的SQL语句
    //时间:2007.11.10
    //=================================================
    public static  void execnonsql(string sql)
    {
        try
        {
            OleDbConnection conn = DB.Getconn();
            OleDbCommand com = new OleDbCommand(sql, conn);
            com.ExecuteNonQuery();
        }
        catch (Exception e)
        {
            throw new Exception(e.Message);
        }
        finally
        {
            closeConnection();
        }

    }
    //=================================================
    //功能描述:获取DATASET
    //输入参数:sql,查询的SQL语句
    //返回值:DataSet
    //时间:2007.11.10
    //=================================================
    public static DataSet getdataset(string sql)
    {
        try
        {
            OleDbConnection conn = DB.Getconn();
            OleDbDataAdapter adp = new OleDbDataAdapter(sql, conn);
            DataSet ds = new DataSet();
            adp.Fill(ds, "ds");
            return ds;
        }
        catch (Exception e)
        {
            throw new Exception(e.Message);
        
        }
        finally
        {
         closeConnection();
        }
    }
    //=================================================
    //功能描述:获取DATASET1
    //输入参数:sql,查询的SQL语句
    //返回值:DataSet
    //时间:2007.11.10
    //=================================================
    public static DataSet select(string sql,string tablename)
    {
        try
        {
            OleDbConnection conn = DB.Getconn();
            OleDbDataAdapter adp = new OleDbDataAdapter(sql, conn);
            DataSet ds = new DataSet();
            adp.Fill(ds, tablename);
            return ds;
        }
        catch (Exception e)
        {
            throw new Exception(e.Message);

        }
        finally
        {
            closeConnection();
        }
    }
    //=================================================
    //功能描述:获取某个字段数据
    //输入参数:sql,查询的SQL语句
    //返回值:hang
    //时间:2007.11.10
    //=================================================
    public static string FindString(string sql)
    {
        try
        {
            OleDbConnection conn = DB.Getconn();
            OleDbCommand com = new OleDbCommand(sql, conn);
            string hang = Convert.ToString(com.ExecuteScalar());
            return hang;
        }
        catch (Exception e)
        {
            throw new Exception(e.Message);

        }
        finally
        {
            closeConnection();
        }

    }

    /// <summary>
    /// 从数据库中删除数据
    /// </summary>
    /// <param name="deleteCommandText">一个String,是将要由SqlCommand执行的Transact-SQL SELECT 语句</param>
    /// <returns>返回值是布尔值,表示是否执行成功</returns>
    public bool DeleteData(string deleteCommandText)
    {
        OleDbConnection conn = DB.Getconn();
        System.Data.OleDb.OleDbCommand myCmd;
     
        myCmd = new System.Data.OleDb.OleDbCommand(deleteCommandText, conn);
        myCmd.ExecuteNonQuery();
        myCmd.Dispose();
        conn.Close();
        return true;

    }
    //=================================================
    //功能描述:对DATAGRIG进行数据绑定,无排序
    //输入参数:sql,查询的SQL语句;dg,需要绑定的DATAGRID控件
    //返回值:无
    //时间:2007.11.10
    //=================================================
    public static void binddatagrid(string sql, DataGrid dg)
    {

        try
        {
            DataSet ds = getdataset(sql);
            dg.DataSource = ds.Tables[0].DefaultView;
            dg.DataBind();
        }
        catch (Exception e)
        {
            throw new Exception(e.Message);
        
        }
        finally
        {
         closeConnection();
        }
    }
    //=================================================
    //功能描述:对DropDownList进行数据绑定,无排序
    //输入参数:sql,查询的SQL语句;dg,需要绑定的DATAGRID控件
    //返回值:无
    //时间:2007.11.10
    //=================================================
    public static void bindDropDownList(string sql, DropDownList dl, string class_name, string id)
    {

        try
        {
            DataSet ds = getdataset(sql);
            dl.DataSource = ds.Tables[0].DefaultView;
            dl.DataTextField = class_name;
            dl.DataValueField = id;
            dl.DataBind();
        }
        catch (Exception e)
        {
            throw new Exception(e.Message);

        }
        finally
        {
            closeConnection();
        }
    }
    //=================================================
    //功能描述:对RadioButtonList进行数据绑定,无排序
    //输入参数:sql,查询的SQL语句;dg,需要绑定的DATAGRID控件
    //返回值:无
    //时间:2007.11.10
    //=================================================
    public static void bindRadioButtonList(string sql, RadioButtonList rl, string class_name, string id)
    {

        try
        {
            DataSet ds = getdataset(sql);
            rl.DataSource = ds.Tables[0].DefaultView;
            rl.DataTextField = class_name;
            rl.DataValueField = id;
            rl.SelectedIndex = 0;
            rl.DataBind();
        }
        catch (Exception e)
        {
            throw new Exception(e.Message);

        }
        finally
        {
            closeConnection();
        }
    }
    //=================================================
    //功能描述:对GridView进行数据绑定,无排序
    //输入参数:sql,查询的SQL语句;dg,需要绑定的DATAGRID控件
    //返回值:无
    //时间:2007.11.10
    //=================================================
    public static void bindGridView(string sql, GridView dg)
    {
        try
        {
            OleDbConnection conn = DB.Getconn();
            DataSet ds = getdataset(sql);
            dg.DataSource = ds.Tables[0].DefaultView;
            dg.DataBind();
        }
        catch (Exception e)
        {
            throw new Exception(e.Message);

        }
        finally
        {
            closeConnection();
        }
    }
    //=================================================
    //功能描述:对datalist进行数据绑定,无排序
    //输入参数:sql,查询的SQL语句;dl,需要绑定的datalist控件
    //返回值:无
    //时间:2007.11.10
    //=================================================
    public static void binddatalist(string sql, DataList dl)
    {
        try
        {
            OleDbConnection conn = DB.Getconn();
            DataSet ds = getdataset(sql);
            dl.DataSource = ds.Tables[0].DefaultView;
            dl.DataBind();
        }
        catch (Exception e)
        {
            throw new Exception(e.Message);

        }
        finally
        {
            closeConnection();
        }
    }
    //=================================================
    //功能描述:对repeater进行数据绑定,无排序
    //输入参数:sql,查询的SQL语句;dl,需要绑定的repeater控件
    //返回值:无
    //时间:2007.11.10
    //=================================================
    public static void bindrepeater(string sql, Repeater rp)
    {
        try
        {
            OleDbConnection conn = DB.Getconn();
            DataSet ds = getdataset(sql);
            rp.DataSource = ds.Tables[0].DefaultView;
            rp.DataBind();
        }
        catch (Exception e)
        {
            throw new Exception(e.Message);

        }
        finally
        {
            closeConnection();
        }
    }
    //=================================================
    //功能描述:对listbox进行数据绑定
    //输入参数:sql,查询的SQL语句;listb,需要绑定的listbox控件
    //返回值:无
    //时间:2007.11.10
    //=================================================
    public static void bindlistbox(string sql, ListBox listb, string class_name, string id)
    {
        try
        {
            OleDbConnection conn = DB.Getconn();
            DataSet ds = getdataset(sql);
            listb.DataSource = ds.Tables[0].DefaultView;
            listb.DataTextField = class_name;
            listb.DataValueField = id;
            listb.DataBind();
        }
        catch (Exception e)
        {
            throw new Exception(e.Message);

        }
        finally
        {
            closeConnection();
        }
    }
    /// <summary>
    /// 返回 HTML 字符串的编码结果
    /// </summary>
    /// <param name="str">字符串</param>
    /// <returns>编码结果</returns>
    public static string HtmlEncode(string str)
    {
        return HttpUtility.HtmlEncode(str);
    }

    /// <summary>
    /// 返回 HTML 字符串的解码结果
    /// </summary>
    /// <param name="str">字符串</param>
    /// <returns>解码结果</returns>
    public static string HtmlDecode(string str)
    {
        return HttpUtility.HtmlDecode(str);
    }
    /// <summary>
    /// 检测是否有Sql危险字符
    /// </summary>
    /// <param name="str">要判断字符串</param>
    /// <returns>判断结果</returns>
    public static bool IsSafeSqlString(string str)
    {

        return !Regex.IsMatch(str, @"[-|;|,|\/|\(|\)|\[|\]|\}|\{|%|@|\*|!|\']");
    }
    /// <summary>
    /// 检测用户登录。
    /// </summary>
    /// <param name="ID"></param>
    /// <returns></returns>
    public static string UserCheck(string username,string userpass)
    {
        string strsql = "select count(*) from Member where mem_Name='" + username + "' and mem_Password='"+userpass+"'";
        OleDbConnection conn = DB.Getconn();
        OleDbCommand com = new OleDbCommand(strsql, conn);
        string hang = Convert.ToString(com.ExecuteScalar());
        return hang;
    }

   

}
搜索更多相关主题的帖子: 未指定的错误 
2008-09-18 17:40
快速回复:未指定的错误
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.019267 second(s), 10 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved