using System;
using System.Collections.Generic;
using System.Text;
using System.Conguration;
using System.Data.SqlClient;
using System.Data;
using System.Collections;
namespace Item.Common
{
class Connection
{
//初始化连接对象
private static SqlConnection _objCon = new
SqlConnection("server=.;uid=chenlei;pwd=stoneschen;database=WareFlow");
private static SqlCommand _objCom = null;
private static SqlDataAdapter _objAda = null;
private static SqlTransaction _objTran = null;
// 执行增、删、改操作
public static int ExecuteData(string SQL)
{
//初始化命令对象
_objCom = new SqlCommand(SQL, _objCon);
//所影响行数
int rowCount = 0;
try
{
//打开连接
_objCon.Open();
//执行插入语句
rowCount = _objCom.ExecuteNonQuery();
}
catch (SqlException e)
{
rowCount = -1;
throw e;
}
%nally
{
//关闭连接
_objCon.Close();
}
return rowCount;
}
// 查询并返回DataSet
public static DataSet ExecuteQuery(string SQL, string table)
{
_objAda = new SqlDataAdapter(SQL, _objCon);
try
{
//打开连接
_objCon.Open();
//新建数据集