您的位置:首页 > 数据库

Asp.Net+Sql Server之C#编写的操作Sql Server存储过程的类

2007-11-01 14:13 453 查看
       #region 定义新SqlConnection,SqlCommand...........
    SqlConnection con;
    SqlCommand com;
    SqlDataAdapter adpt;
    DataSet ds;
    SqlDataReader dr;
    #endregion
    #region 连接数据库
    public sqldb()
    {
        con = new SqlConnection();
        com = new SqlCommand();
        adpt = new SqlDataAdapter();
        ds = new DataSet();
        //dr = new SqlDataReader();
        con.ConnectionString = ConfigurationSettings.AppSettings["guo752"];
    }
    #endregion

 #region 执行存储过程
    public void execProc(string procName, SqlParameter[] Params)
    {
        con.Open();
        com = new SqlCommand(procName, con);
        com.CommandType = CommandType.StoredProcedure;
        foreach(SqlParameter parameter in Params)
        {
            com.Parameters.Add(parameter);
        }
        com.ExecuteNonQuery();
        con.Close();
    }
    #endregion 
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
相关文章推荐