I am learning VB exp 2008 with a book in my hand......
I would like to use a textbox in a panel to input 4 numeric characters, then pass that data to an opening string for an ADONet connection to an access database in order to select a particular record
I thought to use the textbox TextChanged event to count 4 character entry then create the request without having to click a "go" button. (I'm not interested at the moment on the error checking for numerics).
I open the database connection in the form load event using the following:
m_cnADONetConnection.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\visual_basic_tests\test1.mdb"
but thought to submit the 4 digit numeric ID from the TextChanged event after 4 characters are entered (and checked!) like this: (the numbers are held in an integer variable intIDNumber and the database field to be searched is ID_Number)
m_daDataAdapter = New OleDb.OleDbDataAdapter("Select * From TestTable where ID_Number = intIDNumber", m_cnADONetConnection)
m_cbCommandBuilder = New OleDb.OleDbCommandBuilder(m_daDataAdapter)
I am not sure how to write the TextChanged code to loop until 4 characters are entered then
select the record, close the panel and display the result in textboxes in another panel.
I got this far then realised I hadn't a clue what to do next!
Private Sub txtGetData1_TextChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles txtGetData1.TextChanged
strResult = txtGetData1.Text
intIDNumber = CInt(strResult)
intCount = intCount + 1
If intCount = 4 Then
intCount is declared in the class declarations at the top of the form
In another test i have successfully populated the m_dataAdapter with all the records and can display and move through the records and change and save, so the connection works (using the select * without the where) but I need to select a single record for global use over several forms.
Hope its clear!
There will be more....