做爰高潮a片〈毛片〉,尤物av天堂一区二区在线观看,一本久久A久久精品VR综合,添女人荫蒂全部过程av

最新文章專題視頻專題問答1問答10問答100問答1000問答2000關鍵字專題1關鍵字專題50關鍵字專題500關鍵字專題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關鍵字專題關鍵字專題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
當前位置: 首頁 - 科技 - 知識百科 - 正文

.net連接Mysql封裝類代碼 可直接調用

來源:懂視網 責編:小采 時間:2020-11-27 22:40:38
文檔

.net連接Mysql封裝類代碼 可直接調用

.net連接Mysql封裝類代碼 可直接調用:微軟的visual studio沒有自帶連接Mysql的驅動,要去網上下載一個mysql-connector-net-6.4.3驅動,然后安裝就可以使用。下面是我封裝好的連接數據庫的類,直接調用即可。 代碼如下:using System;using System.Collections.Gener
推薦度:
導讀.net連接Mysql封裝類代碼 可直接調用:微軟的visual studio沒有自帶連接Mysql的驅動,要去網上下載一個mysql-connector-net-6.4.3驅動,然后安裝就可以使用。下面是我封裝好的連接數據庫的類,直接調用即可。 代碼如下:using System;using System.Collections.Gener

微軟的visual studio沒有自帶連接Mysql的驅動,要去網上下載一個mysql-connector-net-6.4.3驅動,然后安裝就可以使用。
下面是我封裝好的連接數據庫的類,直接調用即可。
代碼如下:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data;
using System.Data.SqlClient;
using System.Configuration;
using MySql.Data.MySqlClient;
namespace DAL
{
  public class GetConnection
    {
        private static MySqlConnection  _connection;
      /// <summary>
      /// 獲取數據庫連接橋
      /// </summary>
        private static MySqlConnection Connection
        {
            get
            {
               //string connectionString = ConfigurationManager.AppSettings["ConnectionString"];
                string connectionString = "server=localhost;user id=root; password=root; database=system; pooling=false";
                //server=222.222.222.222;port=3306;uid=user;pwd=;database=basename;遠程連接的
                //string connectionString = "Data Source=202.192.72.22;Initial Catalog=wwj;Persist Security Info=True;User ID=wwj;Password=wwj123";
                if (_connection == null)
                {
                    _connection = new MySqlConnection(connectionString);
                    _connection.Open();
                }
                if (_connection.State == ConnectionState.Closed)
                {
                    _connection.Open();
                }
                if (_connection.State == ConnectionState.Broken)
                {
                    _connection.Close();
                    _connection.Open();
                }
                return GetConnection._connection;
            }
        }
      /// <summary>
      /// 獲取表數據
      /// </summary>
      /// <param name="sql"></param>
      /// <returns></returns>
        public static MySqlDataReader GetDataRead(string sql)
        {
            MySqlCommand command = new MySqlCommand(sql, Connection);
            MySqlDataReader read = command.ExecuteReader();
            return read;
        }
        public static int NoSelect(string sql)
        {
            MySqlCommand command = new MySqlCommand(sql, Connection);
            int row = command.ExecuteNonQuery();
            return row;
        }
        public static DataTable GetDataTable(string sql)
        {
            MySqlCommand command = new MySqlCommand(sql, Connection);
            DataTable dt = new DataTable();
            MySqlDataAdapter sda = new MySqlDataAdapter(command);
            sda.Fill(dt);
            return dt;
        }
        /// <summary>
        /// 執行sql語句,返回一行一列。
        /// </summary>
        /// <param name="sql">SQL語句</param>
        /// <returns></returns>
        public static string GetScalar(string sql)
        {
            MySqlCommand command = new MySqlCommand(sql, Connection);
            return command.ExecuteScalar().ToString();
        }
    }
}

比如說你想執行刪除的,你可以調用GetConnection.NoSelect("delete from UserInfo where Id=1");讀數據庫的某一張表,可以調用GetConnection.GetDataTable("select * from UserInfo");調用都很方便。

聲明:本網頁內容旨在傳播知識,若有侵權等問題請及時與本網聯系,我們將在第一時間刪除處理。TEL:177 7030 7066 E-MAIL:11247931@qq.com

文檔

.net連接Mysql封裝類代碼 可直接調用

.net連接Mysql封裝類代碼 可直接調用:微軟的visual studio沒有自帶連接Mysql的驅動,要去網上下載一個mysql-connector-net-6.4.3驅動,然后安裝就可以使用。下面是我封裝好的連接數據庫的類,直接調用即可。 代碼如下:using System;using System.Collections.Gener
推薦度:
標簽: 數據庫 封裝 net
  • 熱門焦點

最新推薦

猜你喜歡

熱門推薦

專題
Top
主站蜘蛛池模板: 且末县| 阜南县| 江西省| 阳朔县| 铜陵市| 五原县| 黔江区| 博客| 酒泉市| 鸡泽县| 平罗县| 永定县| 沭阳县| 洛扎县| 宜都市| 郁南县| 四川省| 西贡区| 陕西省| 宣城市| 文山县| 合阳县| 九龙城区| 安丘市| 肃北| 汶上县| 秦皇岛市| 三河市| 淄博市| 新和县| 兰州市| 吉水县| 衡南县| 望奎县| 隆化县| 上思县| 小金县| 抚宁县| 乌苏市| 麟游县| 洞头县|