using System;
using System
using System
using System
using System
比如
// 打開數據庫
轉自
public static SqlConnection OpenConnection()
{
SqlConnection mysqlConn = new SqlConnection(ConfigurationSettings
try
{
mysqlConn
}
catch (Exception e)
{
//rethrow this exception
throw e;
}
return mysqlConn;
}
// 執行SQL返回DataSet
public static DataSet GetDataSet(string SQLQuery)
{
SqlConnection cn = DBObject
SqlDataAdapter da = new SqlDataAdapter(SQLQuery
DataSet ds = new DataSet();
da
//release resources
da
da = null;
cn
cn = null;
return ds;
}
// 執行SQL語句
public static void ExecuteUpdateQuery(string SQLQuery)
{
SqlConnection cn = DBObject
SqlCommand cmd = new SqlCommand();
cmd
cmd
cmd
cmd
cn
cn = null;
}
From:http://tw.wingwit.com/Article/program/net/201311/13695.html