vb.net - How to Trigger Code with ComboBox Change Event -


i have created database containing historical stock prices. on form have 2 comboboxes, combobox_ticker , combobox_date. when these comboboxes filled want check database , see if respective data exists in database. if want change text of label called label_if_present "in database".

my problem occurs change event. want of happen once change data in textboxes. have tried both .textchanged , .lostfocus events. '.textchanged' triggers code , throws , error in sql command statement. `.lostfocus' event doesn't trigger code @ all.

here current code:

public databasename string = "g:\programming\nordeen investing 3\ni3 database.mdb" public con new oledb.oledbconnection("provider=microsoft.jet.oledb.4.0;data source =" & databasename) public tblname string = "historical_stock_prices"  private sub change_labels(byval sender object, byval e eventargs) handles combobox_ticker.textchanged, combobox_date.textchanged     con.close()     dim dr oledbdatareader     con.open()     if (file.exists(databasename))         dim restrictions(3) string         restrictions(2) = tblname         dim dbtbl datatable = con.getschema("tables", restrictions)         if dbtbl.rows.count = 0         else             dim cmd2 new oledb.oledbcommand("select * " & tblname & "  ticker = '" & combobox_ticker.text & "' " & "  ,  date1 = '" & combobox_date.text & "'", con)             dr = cmd2.executereader             if dr.read() = 0                 'if record not exist                 label_if_present.text = ""             else                 label_if_present.text = "in database"             end if             con.close()         end if     else     end if end sub 

i have implemented concept on other forms within project. 1 different , can't figure out why can't 1 work.

handling textchanged event should work, need set dropdownstyle dropdownlist text property can given value.
check see both comboboxes have values selected. should work:

  if combobox_ticker.text <> "" andalso datetime.tryparse(combobox_date.text, nothing) 

Comments

Popular posts from this blog

curl - PHP fsockopen help required -

HTTP/1.0 407 Proxy Authentication Required PHP -

c# - Resource not found error -