濮阳杆衣贸易有限公司

主頁 > 知識(shí)庫 > ADO.NET通用數(shù)據(jù)庫訪問類

ADO.NET通用數(shù)據(jù)庫訪問類

熱門標(biāo)簽:地圖標(biāo)注的公司有哪些 遂寧市地圖標(biāo)注app 塔城代理外呼系統(tǒng) 濮陽外呼電銷系統(tǒng)怎么樣 地圖定位圖標(biāo)標(biāo)注 400電話辦理哪家性價(jià)比高 天心智能電銷機(jī)器人 地圖標(biāo)注專業(yè)團(tuán)隊(duì) 代理接電話機(jī)器人如何取消

本文實(shí)例為大家分享了ADO.NET通用數(shù)據(jù)庫訪問類,供大家參考學(xué)習(xí),具體內(nèi)容如下

using System;

using System.Collections.Generic;

using System.Linq;

using System.Text;

using System.Threading.Tasks;



using System.Data;

using System.Data.SqlClient;



namespace Test

{

  public class DBHelper

  {

    public static string ConString = "Data Source=.;Initial Catalog=bankdb;User id=sa;Password=123;";



    //執(zhí)行增刪改的方法

    public static int RunNoQuery(string cmdText, CommandType cmdType, params SqlParameter[] pars)

    {

      SqlConnection con = new SqlConnection(ConString);

      con.Open();

      SqlCommand cmd = new SqlCommand(cmdText, con);

      cmd.CommandType = cmdType;

      if (pars != null  pars.Length > 0)

      {

        foreach (SqlParameter p in pars)

        {

          cmd.Parameters.Add(p);

        }

      }

      int rows = cmd.ExecuteNonQuery();

      con.Close();

      return rows;

    }



    //執(zhí)行查詢(DataSet)的方法

    public static DataSet RunSelect(string cmdText, CommandType cmdType, params SqlParameter[] pars)

    {

      SqlConnection con = new SqlConnection(ConString);

     

      SqlDataAdapter da = new SqlDataAdapter(cmdText, con);

      da.SelectCommand.CommandType = cmdType;

      if (pars != null  pars.Length > 0)

      {

        foreach (SqlParameter p in pars)

        {

          da.SelectCommand.Parameters.Add(p);

        }

      }

      DataSet ds = new DataSet();

      da.Fill(ds);



      return ds;

    }



    //執(zhí)行查詢得到一個(gè)值

    public static object RunOneValue(string cmdText, CommandType cmdType, params SqlParameter[] pars)

    {

      SqlConnection con = new SqlConnection(ConString);

      con.Open();

      SqlCommand cmd = new SqlCommand(cmdText, con);

      cmd.CommandType = cmdType;

      if (pars != null  pars.Length > 0)

      {

        foreach (SqlParameter p in pars)

        {

          cmd.Parameters.Add(p);

        }

      }

      object obj = cmd.ExecuteScalar();

      con.Close();

      return obj;

    }

  }

}

以上就是本文的全部內(nèi)容,希望對(duì)大家的學(xué)習(xí)有所幫助。

您可能感興趣的文章:
  • Mysql 數(shù)據(jù)庫訪問類
  • ASP.NET封裝的SQL數(shù)據(jù)庫訪問類
  • linux mysql 數(shù)據(jù)庫開啟外部訪問設(shè)置指南
  • C#訪問PostGreSQL數(shù)據(jù)庫的方法
  • SQLServer 數(shù)據(jù)庫變成單個(gè)用戶后無法訪問問題的解決方法
  • MySQL數(shù)據(jù)庫設(shè)置遠(yuǎn)程訪問權(quán)限方法小結(jié)
  • mysql設(shè)置遠(yuǎn)程訪問數(shù)據(jù)庫的多種方法
  • Python 分析Nginx訪問日志并保存到MySQL數(shù)據(jù)庫實(shí)例
  • c#編寫的高并發(fā)數(shù)據(jù)庫控制訪問代碼
  • ASP.NET對(duì)SQLServer的通用數(shù)據(jù)庫訪問類

標(biāo)簽:婁底 汕頭 麗江 重慶 本溪 河南 宜春 吉林

巨人網(wǎng)絡(luò)通訊聲明:本文標(biāo)題《ADO.NET通用數(shù)據(jù)庫訪問類》,本文關(guān)鍵詞  ADO.NET,通用,數(shù)據(jù)庫,訪問,;如發(fā)現(xiàn)本文內(nèi)容存在版權(quán)問題,煩請?zhí)峁┫嚓P(guān)信息告之我們,我們將及時(shí)溝通與處理。本站內(nèi)容系統(tǒng)采集于網(wǎng)絡(luò),涉及言論、版權(quán)與本站無關(guān)。
  • 相關(guān)文章
  • 下面列出與本文章《ADO.NET通用數(shù)據(jù)庫訪問類》相關(guān)的同類信息!
  • 本頁收集關(guān)于ADO.NET通用數(shù)據(jù)庫訪問類的相關(guān)信息資訊供網(wǎng)民參考!
  • 推薦文章
    江华| 浠水县| 太仆寺旗| 绿春县| 佛教| 靖州| 台中市| 龙口市| 东乡族自治县| 星子县| 荣成市| 七台河市| 田林县| 无棣县| 宿州市| 达孜县| 汽车| 万山特区| 珠海市| 金沙县| 东安县| 曲水县| 宁武县| 侯马市| 汉寿县| 黄浦区| 龙州县| 瑞昌市| 诸暨市| 拜城县| 星子县| 新密市| 萍乡市| 瑞丽市| 江华| 公安县| 沂水县| 土默特左旗| 灵台县| 朔州市| 丰原市|