仿Petshop寫的資料庫操作類

2021-04-01 21:22:48 字數 3085 閱讀 2495

using system;

using system.componentmodel;

using system.collections;

using system.diagnostics;

using system.data;

using system.data.sqlclient;

using system.configuration;

namespace my.components

///

/// run stored procedure.

///

/// name of stored procedure.

/// stored procedure params.

/// stored procedure return value.

public int runproc(string procname, sqlparameter prams)

///

/// run stored procedure.

///

/// name of stored procedure.

/// return result of procedure.

public void runproc(string procname, out sqldatareader datareader)

///

/// run stored procedure.

///

/// name of stored procedure.

/// stored procedure params.

/// return result of procedure.

public void runproc(string procname, sqlparameter prams, out sqldatareader datareader)

///

/// create command object used to call stored procedure.

///

/// name of stored procedure.

/// params to stored procedure.

/// command object.

private sqlcommand createcommand(string procname, sqlparameter prams)

// return param

cmd.parameters.add(

new sqlparameter("returnvalue", sqldbtype.int, 4,

parameterdirection.returnvalue, false, 0, 0,

string.empty, datarowversion.default, null));

return cmd;

}///

/// open the connection.

///

///

/// close the connection.

///

public void close()

///

/// release resources.

///

public void dispose()

}///

/// make input param.

///

/// name of param.

/// param type.

/// param size.

/// param value.

/// new parameter.

public sqlparameter makeinparam(string paramname, sqldbtype dbtype, int size, object value)

///

/// make input param.

///

/// name of param.

/// param type.

/// param size.

/// new parameter.

public sqlparameter makeoutparam(string paramname, sqldbtype dbtype, int size)

///

/// make stored procedure param.

///

/// name of param.

/// param type.

/// param size.

/// parm direction.

/// param value.

/// new parameter.

public sqlparameter makeparam(string paramname, sqldbtype dbtype, int32 size, parameterdirection direction, object value)

///

/// 執行sql

///

///

///

///

///

/// 建立資料集

///

///

///

///

///

///

///

sqlcommand sqlcmd=new sqlcommand(strquery,con);   

trycatch(exception e)

sqldataadapter da=new sqldataadapter();

da.selectcommand=sqlcmd;

dataset ds=new dataset();

da.fill(ds,strtable);

da.dispose();

return ds.tables[strtable];

}///

/// 得到結果集數

///

///

/// }}

mysql仿asp的資料庫操作類

具體 如下所示 php class mysqldb function mysqldb tablename database slt 建構函式 this dbid mysql select db database if this dbid function isempty value function...

php操作MYSQL資料庫自寫的函式

返回陣列結果 a array 連線地址 登入名 登入密碼 資料庫名 埠 a array 127.0.0.1 root 123 mysql 3306 sqlrun a,select now sqlrun function sqlrun cto array 127.0.0.1 root 123 mysq...

自己寫的通過ADO操作mysql資料庫

include include include import c program files common files system ado msado15.dll no namespace rename eof adoeof rename bof adobof class adoconn virt...

仿微信 介面動畫 6 資料庫的簡易操作

下面簡述了一下如何建立資料庫,如何增刪改查,以及資料庫的新增列的操作 1.簡歷資料庫,首先建立一個資料庫的輔助類mydatabasehelper繼承的是sqliteopenhelper 資料庫操作的輔助類 public class mydatabasehelper extends sqliteope...

資料庫 基礎資料庫的操作

什麼是資料庫 資料庫 database 是按照資料結構來組織 儲存和管理資料的倉庫 常見的資料庫oracle mysql sun db2 ibm sql server microsoft postgre sql 專業術語 資料庫系統 database system dbs 資料庫 database ...