using System;
using System.Configuration;
using System.Data.SqlClient;
using System.Data;
using System.Collections;
比如:
// 打开数据库
try
{
mysqlConn.Open();
}
catch (Exception e)
{
//rethrow this exception
throw e;
}
return mysqlConn;
}
// 执行SQL返回DataSet
public static DataSet GetDataSet(string SQLQuery)
{
SqlConnection cn = DBObject.OpenConnection();
SqlDataAdapter da = new SqlDataAdapter(SQLQuery, cn);
DataSet ds = new DataSet();
da.Fill(ds);
//release resources
da.Dispose();
da = null;
cn.Close();
cn = null;
return ds;
}
// 执行SQL语句
public static void ExecuteUpdateQuery(string SQLQuery)
{
SqlConnection cn = DBObject.OpenConnection();
SqlCommand cmd = new SqlCommand();
cmd.CommandText = SQLQuery;
cmd.CommandType = CommandType.Text;
cmd.Connection = cn;
cmd.ExecuteNonQuery();
cn.Close();
cn = null;
}
Word教程网 | Excel教程网 | Dreamweaver教程网 | Fireworks教程网 | PPT教程网 | FLASH教程网 | PS教程网 |
HTML教程网 | DIV CSS教程网 | FLASH AS教程网 | ACCESS教程网 | SQL SERVER教程网 | C语言教程网 | JAVASCRIPT教程网 |
ASP教程网 | ASP.NET教程网 | CorelDraw教程网 |