ado.net 調用帶參數的存儲過程

    String connString = "Data Source = localhost; Initial Catalog = hkjc;User ID = sa;Pwd = 123";
            SqlConnection conn = new SqlConnection(connString);
            conn.Open();
            SqlCommand cmd = new SqlCommand("GetManagement", conn);
            cmd.CommandType = CommandType.StoredProcedure;
            cmd.Parameters.Add("@management", SqlDbType.VarChar, 50).Value = managementname;
            SqlDataAdapter sda = new SqlDataAdapter(cmd);
            DataTable dt=new DataTable();
            sda.Fill(dt);
            cmd.Dispose();
            cmd.Clone();
            conn.Dispose();
            conn.Close();
            return dt;cmd

 

注:GetManagement爲存儲過程名稱  @management爲參數名稱it

相關文章
相關標籤/搜索