C 資料庫操作類

2021-06-20 09:18:55 字數 2295 閱讀 2951

using system;

using system.collections.generic;

using system.linq;

using system.web;

using system.data.oledb;

using system.data;

using system.configuration;

using system.data.sql;

using system.data.sqlclient;

namespace dal

tryelse

return false;

}catch (exception e)

finally

}/// /// 執行sql語句的查詢,返回查詢的數量。異常返回-1.

///

///

///

///

///

public static int excequery(string sql, commandtype type, idataparameter pars)

tryelse

return -1;

}catch (exception e)

finally

}/// /// 執行查詢,返回乙個資料集

///

///

///

///

public static dataset excuereturndataset(string sql, idataparameter pars)

sqldataadapter adpter = new sqldataadapter(com);

trycatch (exception ex)

finally

}public static dataset excuereturndataset(string sql,commandtype type,idataparameter pars)

sqldataadapter adpter = new sqldataadapter(com);

trycatch (exception ex)

finally

}public static idatareader excuereturndatareader(string sql, idataparameter pars)

trycatch (exception ex)

finally

}/// /// 執行儲存過程,返回影響的行數

///

/// 儲存過程名

/// 儲存過程引數

/// 影響的行數

///

public static int runprocedure(string storedprocname, idataparameter parameters, out int rowsaffected)

command.parameters.add("@return","").direction = parameterdirection.returnvalue;

rowsaffected = command.executenonquery();

result = (int)command.parameters["@return"].value;

connection.close();

return result;}}

/// /// 執行儲存過程

///

/// 儲存過程名

/// 儲存過程引數

/// dataset結果中的表名

/// dataset

public static dataset runprocedure(string storedprocname, idataparameter parameters, string tablename)

sqldataadapter adpter = new sqldataadapter(com);

adpter.fill(dataset, tablename);

return dataset;}}

/// /// 執行查詢語句,返回dataset

///

/// 查詢語句

/// dataset

public dataset query(string sqlstring)

catch (system.data.sqlclient.sqlexception ex)

return ds;}}

}}

原作者不詳,**【

c 資料庫操作類

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

Oracle資料庫操作類(c )

用oracleconnection連線oracle 在web.config中配置 oracle value data source user id password public system.data.oracleclient.oracleconnection cnn 開啟資料庫連線 public...

C 操作mysql資料庫類

標頭檔案 cmysql.h 1 ifndef cmysql h 2 define cmysql h 3 4 include 5 include 6 include 7 include 8 9 using namespace std 10 11 class cmysql 12 26 27 endif ...