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 = 34;
            parms[1].Value = "|河南省|";
            parms[2].Value = "郑州";
            parms[3].Value = "112";
            comm.Parameters.AddRange(parms);
            conn.Open();
            SqlDataAdapter sda = new SqlDataAdapter(comm);
            DataSet ds = new DataSet();
            sda.Fill(ds);
            rep.DataSource = ds;
            rep.DataBind();

posted @ 2015-01-26 22:50  net5x  阅读(460)  评论(0编辑  收藏  举报