C 實現MySQL通用操作類

2021-09-26 20:20:44 字數 2700 閱讀 4498

如有錯誤,歡迎各位提出哈~

using system;

using system.collections;

using system.collections.generic;

using system.configuration;

using system.data;

using system.linq;

using system.text;

using system.threading.tasks;

using mysql.data.mysqlclient;}}

///

/// 執行查詢操作,返回datatable

///

///

///

///

///

public

static

datatable

executedatatable

(string commandtext,

commandtype commandtype,

params mysqlparameter[

] parameters)}}

///

/// 執行查詢操作,返回mysqldatareader

///

///

///

///

///

public

static

mysqldatareader

executereader

(string commandtext,

commandtype commandtype,

params mysqlparameter[

] parameters)

catch

}///

/// 執行查詢操作,返回第一行第一列

///

///

///

///

///

public

static

object

executescalar

(string commandtext,

commandtype commandtype,

params mysqlparameter[

] parameters)

}///

/// 執行非查詢操作,返回受影響的行數

///

///

///

///

///

public

static

intexecutenonquery

(string commandtext,

commandtype commandtype,

params mysqlparameter[

] parameters)

catch}}

///

/// 執行資料庫事務,不帶引數

///

///

///

public

static

intexecutenonquery

(ilist<

string

> list)

transaction.

commit()

;return count;

}catch}}

///

/// 執行資料庫事務,帶引數

///

///

///

public

static

intexecutenonquery

(hashtable hashtable)

transaction.

commit()

;return count;

}catch}}

///

/// 設定mysqlcommand

///

///

///

///

///

///

///

private

static

void

preparecommand

(mysqlconnection connection,

mysqlcommand command,

mysqltransaction transaction,

string commandtext,

commandtype commandtype,

params mysqlparameter[

] parameters)

command.connection = connection;

// 設定sqlif(

!string

.isnullorempty

(commandtext)

) command.commandtype = commandtype;

// 開啟事務

if(transaction !=

null

)// 設定引數

if(parameters !=

null

) command.parameters.

add(parameter);}

}}}}

c 操作mysql通用類 C 資料庫操作通用類

usingsystem usingsystem.collections.generic usingsystem.linq usingsystem.text usingsystem.data.common usingsystem.data usingsystem.reflection namespac...

C 操作Access通用類

using system using system.data using system.configuration using system.web using system.web.security using system.web.ui using system.web.ui.webcontro...

c 連線mysql 通用類 資料庫通用連線類

usingsystem usingsystem.data usingsystem.data.sqlclient namespacedataproviders sqldataprovider 的摘要說明。internal classsqldataprovider idataprovider priva...