用代码调用存储过程,我的数据库封装类C

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{

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

public class DbAccess { SqlConnection conn = null; SqlCommand cmd =
null; public DbAccess() { // // TODO: 在此处添加构造函数逻辑 // conn =
new SqlConnection(); 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”];
    }

发表评论

电子邮件地址不会被公开。 必填项已用*标注