首页 > 代码库 > c#中用sql存储过程

c#中用sql存储过程

string connstr = ConfigurationManager.ConnectionStrings["ConnectionString"].ConnectionString;
            SqlConnection conn = new SqlConnection(connstr);
            SqlCommand comm = new SqlCommand();
            comm.Connection = conn;
            comm.CommandType = CommandType.StoredProcedure;
            comm.CommandText = "sd_wish_selected";
            SqlParameter[] parms={
                    new SqlParameter("@product_id", SqlDbType.Int,4),
                    new SqlParameter("@province",SqlDbType.NVarChar,20),
                    new SqlParameter("@city",SqlDbType.NVarChar,20),
                    new SqlParameter("@imei",SqlDbType.NVarChar,50)};
            parms[0].Value = http://www.mamicode.com/34;
            parms[1].Value = "http://www.mamicode.com/|河南省|";
            parms[2].Value = "http://www.mamicode.com/郑州";
            parms[3].Value = "http://www.mamicode.com/112";
            comm.Parameters.AddRange(parms);
            conn.Open();
            SqlDataAdapter sda = new SqlDataAdapter(comm);
            DataSet ds = new DataSet();
            sda.Fill(ds);
            rep.DataSource = ds;
            rep.DataBind();

c#中用sql存储过程