The parameterized query expects the parameter which was not supplied

后端 未结 6 1100
甜味超标
甜味超标 2020-11-27 05:47

I\'m having a problem with my code:

Private Sub TextBox2_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TextBox2.TextChanged         


        
6条回答
  •  刺人心
    刺人心 (楼主)
    2020-11-27 06:33

    SqlConnection conn = new SqlConnection(connectionString);
    
    conn.Open();
    //SelectCustomerById(int x);
    comboBoxEx1.Items.Clear();
    
    SqlCommand comm = new SqlCommand("spSelectCustomerByID", conn);
    //comm.Parameters.Add(new SqlParameter("cust_name", cust_name));
    //comm.CommandText = "spSelectCustomerByID";
    comm.Parameters.Add(new SqlParameter("cust_id", SqlDbType.Int));
    comm.CommandType = CommandType.StoredProcedure;
    comm.ExecuteNonQuery();
    
    SqlDataAdapter sdap = new SqlDataAdapter(comm);
    DataSet dset = new DataSet();
    sdap.Fill(dset, "cust_registrations");
    
    if (dset.Tables["cust_registrations"].Rows.Count > 0)
    {
        comboBoxEx1.Items.Add("cust_registrations").ToString();
    }
    comboBoxEx1.DataSource = dset;
    comboBoxEx1.DisplayMember = "cust_name";
    

提交回复
热议问题