View Single Post
Old Nov 21st, 2005, 12:13 AM   #4
melbolt
Hobbyist Programmer
 
melbolt's Avatar
 
Join Date: Feb 2005
Location: PA, USA
Posts: 244
Rep Power: 4 melbolt is on a distinguished road
Send a message via AIM to melbolt Send a message via Yahoo to melbolt
to do a search, you could use a DataReader.

 

'declare stuff 
Dim DataReader As OleDbDataReader
Dim Command As OleDbCommand
Dim Connection As OleDbConnection 
Dim CustomerIdVar as string = "1234"

'connection string
Connection = New OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=c:\Test.mdb") 

'set up command object to do a select statement taking your var
Command = New OleDbCommand("Select * from Table1 Where CustomerID=" & CustomerIdVar)
Command.Connection = Connection
Command.Connection.Open() 

'Execute the query
DataReader = Command.ExecuteReader() 

If DataReader.HasRows()
   'get the first row returned from the reader and display column in message box, column name in DB is ID
   DataReader.Read()
   msgbox(DataReader.Item("ID").ToString())
else
   'display message
   msgbox("That customer ID was not found")
endif

ok, there are probably errors in my code, I typed it up right here in the code block, but this is just to give you an idea on one way you could set up a search.
__________________
I have never let my schooling interfere with my education. -Mark Twain-

Xbox live gamertag: melbolt
melbolt is offline   Reply With Quote