<span id="mktg5"></span>

<i id="mktg5"><meter id="mktg5"></meter></i>

        <label id="mktg5"><meter id="mktg5"></meter></label>
        最新文章專題視頻專題問答1問答10問答100問答1000問答2000關(guān)鍵字專題1關(guān)鍵字專題50關(guān)鍵字專題500關(guān)鍵字專題1500TAG最新視頻文章推薦1 推薦3 推薦5 推薦7 推薦9 推薦11 推薦13 推薦15 推薦17 推薦19 推薦21 推薦23 推薦25 推薦27 推薦29 推薦31 推薦33 推薦35 推薦37視頻文章20視頻文章30視頻文章40視頻文章50視頻文章60 視頻文章70視頻文章80視頻文章90視頻文章100視頻文章120視頻文章140 視頻2關(guān)鍵字專題關(guān)鍵字專題tag2tag3文章專題文章專題2文章索引1文章索引2文章索引3文章索引4文章索引5123456789101112131415文章專題3
        問答文章1 問答文章501 問答文章1001 問答文章1501 問答文章2001 問答文章2501 問答文章3001 問答文章3501 問答文章4001 問答文章4501 問答文章5001 問答文章5501 問答文章6001 問答文章6501 問答文章7001 問答文章7501 問答文章8001 問答文章8501 問答文章9001 問答文章9501
        當(dāng)前位置: 首頁(yè) - 科技 - 知識(shí)百科 - 正文

        .net連接ACCESS數(shù)據(jù)庫(kù),網(wǎng)頁(yè)上不停的刷新就報(bào)錯(cuò)

        來源:懂視網(wǎng) 責(zé)編:小采 時(shí)間:2020-11-09 15:26:10
        文檔

        .net連接ACCESS數(shù)據(jù)庫(kù),網(wǎng)頁(yè)上不停的刷新就報(bào)錯(cuò)

        .net連接ACCESS數(shù)據(jù)庫(kù),網(wǎng)頁(yè)上不停的刷新就報(bào)錯(cuò):public class DB { public static OleDbConnection Conn; public static string ConnString;//連接字符串 public DB() { // // TODO: 在此處添加構(gòu)造函數(shù)邏輯 // } public static OleDbConnection Getconn()
        推薦度:
        導(dǎo)讀.net連接ACCESS數(shù)據(jù)庫(kù),網(wǎng)頁(yè)上不停的刷新就報(bào)錯(cuò):public class DB { public static OleDbConnection Conn; public static string ConnString;//連接字符串 public DB() { // // TODO: 在此處添加構(gòu)造函數(shù)邏輯 // } public static OleDbConnection Getconn()

        public class DB { public static OleDbConnection Conn; public static string ConnString;//連接字符串 public DB() { // // TODO: 在此處添加構(gòu)造函數(shù)邏輯 // } public static OleDbConnection Getconn() { ConnString = "Provider=Microsoft.Jet.OLEDB.4

        public class DB
        {
        public static OleDbConnection Conn;
        public static string ConnString;//連接字符串

        public DB()
        {
        //
        // TODO: 在此處添加構(gòu)造函數(shù)邏輯
        //
        }

        public static OleDbConnection Getconn()
        {
        ConnString = "Provider=Microsoft.Jet.OLEDB.4.0;Data source=" + System.Web.HttpContext.Current.Server.MapPath(ConfigurationManager.AppSettings["ConnectionString"].ToString());
        Conn = new OleDbConnection(ConnString);
        //if (Conn.State.Equals(ConnectionState.Closed))
        //{

        // Conn.Open();

        //}

        if (Conn == null)
        {
        Conn = new OleDbConnection(ConnString);
        Conn.Open();
        }
        else if (Conn.State == System.Data.ConnectionState.Closed)
        {
        Conn.Open();
        }
        else if (Conn.State == System.Data.ConnectionState.Broken)
        {
        Conn.Close();
        Conn.Open();
        }
        return Conn;

        }
        //=================================================
        //功能描述:關(guān)閉數(shù)據(jù)庫(kù)
        //時(shí)間:2010.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();
        }
        }
        //=================================================
        //功能描述:執(zhí)行SQL語(yǔ)句
        //輸入?yún)?shù):sql,查詢的SQL語(yǔ)句
        //時(shí)間:2010.11.10
        //=================================================
        public static void execnonsql(string sql)
        {
        try
        {
        closeConnection();
        OleDbConnection conn = DB.Getconn();
        OleDbCommand com = new OleDbCommand(sql, conn);
        com.ExecuteNonQuery();
        }
        catch (Exception e)
        {
        throw new Exception(e.Message);
        }
        finally
        {
        closeConnection();
        }

        }
        //=================================================
        //功能描述:獲取DATASET
        //輸入?yún)?shù):sql,查詢的SQL語(yǔ)句
        //返回值:DataSet
        //時(shí)間:2010.11.10
        //=================================================
        public static DataSet getdataset(string sql)
        {
        try
        {
        closeConnection();
        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
        //輸入?yún)?shù):sql,查詢的SQL語(yǔ)句
        //返回值:DataSet
        //時(shí)間:2010.11.10
        //=================================================
        public static DataSet select(string sql, string tablename)
        {
        try
        {
        closeConnection();
        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();
        }
        }
        //=================================================
        //功能描述:獲取某個(gè)字段數(shù)據(jù)
        //輸入?yún)?shù):sql,查詢的SQL語(yǔ)句
        //返回值:hang
        //時(shí)間:2010.11.10
        //=================================================
        public static string FindString(string sql)
        {
        try
        {
        closeConnection();
        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();
        }

        }
        //=================================================
        //功能描述:對(duì)DATAGRIG進(jìn)行數(shù)據(jù)綁定,無排序
        //輸入?yún)?shù):sql,查詢的SQL語(yǔ)句;dg,需要綁定的DATAGRID控件
        //返回值:無
        //時(shí)間:2010.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();
        }
        }
        //=================================================
        //功能描述:對(duì)DropDownList進(jìn)行數(shù)據(jù)綁定,無排序
        //輸入?yún)?shù):sql,查詢的SQL語(yǔ)句;dg,需要綁定的DATAGRID控件
        //返回值:無
        //時(shí)間:2010.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();
        }
        }
        //=================================================
        //功能描述:對(duì)RadioButtonList進(jìn)行數(shù)據(jù)綁定,無排序
        //輸入?yún)?shù):sql,查詢的SQL語(yǔ)句;dg,需要綁定的DATAGRID控件
        //返回值:無
        //時(shí)間:2010.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();
        }
        }
        //=================================================
        //功能描述:對(duì)GridView進(jìn)行數(shù)據(jù)綁定,無排序
        //輸入?yún)?shù):sql,查詢的SQL語(yǔ)句;dg,需要綁定的DATAGRID控件
        //返回值:無
        //時(shí)間:2010.11.10
        //=================================================
        public static void bindGridView(string sql, GridView dg)
        {
        try
        {
        closeConnection();
        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();
        }
        }
        //=================================================
        //功能描述:對(duì)datalist進(jìn)行數(shù)據(jù)綁定,無排序
        //輸入?yún)?shù):sql,查詢的SQL語(yǔ)句;dl,需要綁定的datalist控件
        //返回值:無
        //時(shí)間:2010.11.10
        //=================================================
        public static void binddatalist(string sql, DataList dl)
        {
        try
        {
        closeConnection();
        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();
        }
        }
        //=================================================
        //功能描述:對(duì)repeater進(jìn)行數(shù)據(jù)綁定,無排序
        //輸入?yún)?shù):sql,查詢的SQL語(yǔ)句;dl,需要綁定的repeater控件
        //返回值:無
        //時(shí)間:2010.11.10
        //=================================================
        public static void bindrepeater(string sql, Repeater rp)
        {
        try
        {
        closeConnection();
        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();
        }
        }
        //=================================================
        //功能描述:對(duì)listbox進(jìn)行數(shù)據(jù)綁定
        //輸入?yún)?shù):sql,查詢的SQL語(yǔ)句;listb,需要綁定的listbox控件
        //返回值:無
        //時(shí)間:2010.11.10
        //=================================================
        public static void bindlistbox(string sql, ListBox listb, string class_name, string id)
        {
        try
        {
        closeConnection();
        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();
        }
        }
        ///


        /// 返回 HTML 字符串的編碼結(jié)果
        ///

        /// 字符串
        /// 編碼結(jié)果
        public static string HtmlEncode(string str)
        {
        return HttpUtility.HtmlEncode(str);
        }

        ///


        /// 返回 HTML 字符串的解碼結(jié)果
        ///

        /// 字符串
        /// 解碼結(jié)果
        public static string HtmlDecode(string str)
        {
        return HttpUtility.HtmlDecode(str);
        }
        ///
        /// 檢測(cè)是否有Sql危險(xiǎn)字符
        ///

        /// 要判斷字符串
        /// 判斷結(jié)果
        public static bool IsSafeSqlString(string str)
        {

        return !Regex.IsMatch(str, @"[-|;|,|\/|\(|\)|\[|\]|\}|\{|%|@|\*|!|\']");
        }
        ///


        /// 檢測(cè)用戶登錄。
        ///

        ///
        ///
        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;
        }

        }

        聲明:本網(wǎng)頁(yè)內(nèi)容旨在傳播知識(shí),若有侵權(quán)等問題請(qǐng)及時(shí)與本網(wǎng)聯(lián)系,我們將在第一時(shí)間刪除處理。TEL:177 7030 7066 E-MAIL:11247931@qq.com

        文檔

        .net連接ACCESS數(shù)據(jù)庫(kù),網(wǎng)頁(yè)上不停的刷新就報(bào)錯(cuò)

        .net連接ACCESS數(shù)據(jù)庫(kù),網(wǎng)頁(yè)上不停的刷新就報(bào)錯(cuò):public class DB { public static OleDbConnection Conn; public static string ConnString;//連接字符串 public DB() { // // TODO: 在此處添加構(gòu)造函數(shù)邏輯 // } public static OleDbConnection Getconn()
        推薦度:
        • 熱門焦點(diǎn)

        最新推薦

        猜你喜歡

        熱門推薦

        專題
        Top
        主站蜘蛛池模板: 日本免费在线中文字幕| 白白国产永久免费视频| 免费人成视频在线观看网站| 在线看片免费不卡人成视频| 亚洲精品国产精品乱码不卡| 亚洲黄色片免费看| 国产天堂亚洲精品| 成年人网站免费视频| 亚洲日韩v无码中文字幕| 亚洲妇女无套内射精| 一级毛片免费观看| 国产精品xxxx国产喷水亚洲国产精品无码久久一区 | 久久午夜夜伦鲁鲁片免费无码影视| 国产一级一片免费播放| 亚洲精品免费在线| a毛片在线看片免费| 亚洲A∨午夜成人片精品网站| 亚洲一区在线视频| 在线看片免费人成视频播| 免费吃奶摸下激烈视频| 亚洲va在线va天堂成人| 曰批全过程免费视频播放网站 | 曰批全过程免费视频免费看| 又粗又大又黑又长的免费视频| 亚洲热线99精品视频| 免费A级毛片无码专区| 亚洲人成综合在线播放| 18以下岁毛片在免费播放| 在线亚洲高清揄拍自拍一品区| av网站免费线看| 免费人成视频x8x8入口| 女同免费毛片在线播放| 亚洲一级毛片免费看| 尤物永久免费AV无码网站| 亚洲精品无码少妇30P| 97人伦色伦成人免费视频| 亚洲中文字幕AV在天堂| 国产成人免费福利网站| 亚洲第一se情网站| 国产一区二区三区在线观看免费| 国产一级a毛一级a看免费视频|