自家的数据库封装类C# Sqlserver

using System;using System.Data;using System.Configuration;using
System.Web;//using System.Web.Security;//using System.Web.UI;//using
System.Web.UI.WebControls;//using
System.Web.UI.WebControls.WebParts;//using
System.Web.UI.HtmlControls;using System.Data.SqlClient;using
System.Text;using System.Collections;namespace mySqlSQLDB{

原稿发表时间为:二零零六-08-02 —— 来源于本人的百度文章 [由搬家工具导入]

public class DbAccess { SqlConnection conn = null; SqlCommand cmd =
null; public DbAccess(卡塔尔(قطر‎ { // // TODO: 在这里处增多构造函数逻辑 // conn =
new SqlConnection(State of Qatar; conn.ConnectionString =
Convert.ToString(System.Configuration.ConfigurationSettings.AppSettings[datasource]);
//conn.ConnectionString = initial catalog=_new;data source=.;user
id=bt;password=btbtbtbt;Connect Timeout=5000; cmd = new SqlCommand();
cmd.Connection = conn; cmd.CommandTimeout = 0; } public DbAccess(string
constr卡塔尔国 { // // TODO: 在这里边增多构造函数逻辑 // co

using System;
using System.Data;
using System.Configuration;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;

using System.Data.SqlClient;

/// <summary>
/// Produce 的摘要表明
/// </summary>
public class Produce
{
    private SqlConnection conn;
    private SqlCommand cmd;
    private SqlDataAdapter sda;
    private DataSet ds;

    public Produce()
{
        conn = new
SqlConnection(ConfigurationManager.ConnectionStrings[“testConn”].ConnectionString);
        cmd = new SqlCommand();
        sda = new SqlDataAdapter();
        ds = new DataSet();     
}

    public DataTable dt()
    {
        sda.SelectCommand = new SqlCommand(“testSelect”);
        sda.SelectCommand.CommandType=CommandType.StoredProcedure;
        sda.Fill(ds,”test”);
        return ds.Tables[“test”];
    }

相关文章