1

how can i change the 'COMP' to be check on what i chose on combo box category?

My textbox is cmbCategory

cmd = New SqlCommand("SELECT * FROM tblOfficeEquipmentSubCategory Where CAT_ID='COMP'", sqlconn)
If sqlconn.State = ConnectionState.Closed Then sqlconn.Open()
Dim sdr As SqlDataReader = cmd.ExecuteReader()
sdr.Close()
John Woo
  • 258,903
  • 69
  • 498
  • 492
ivandinglasan
  • 384
  • 4
  • 15
  • 29

1 Answers1

0

Try something like this:

cmd = New SqlCommand("SELECT * FROM tblOfficeEquipmentSubCategory Where CAT_ID=@Category", sqlconn)
cmd.Parameters.Add("@Category", SqlDbType.NVarChar, -1).Value = cmbCategory.SelectedText
If sqlconn.State = ConnectionState.Closed Then sqlconn.Open()
Dim sdr As SqlDataReader = cmd.ExecuteReader()
sdr.Close()
Andrey Gordeev
  • 30,606
  • 13
  • 135
  • 162
  • sir it returned error Additional information: Invalid parameter Size value '-1'. The value must be greater than or equal to 0. may i note that. this is for a combo box that when i chose a category it will display the corresponding subcategory on combo box 2 – ivandinglasan Mar 25 '13 at 08:09
  • Set `size` to 1000 or whatever you need: `cmd.Parameters.Add("@Category", SqlDbType.NVarChar, 1000)` – Andrey Gordeev Mar 25 '13 at 09:49