Sunday, 19 August 2012

how to search data from access databse in VB6

In Visual Basic 6 if someone trying to access some data from a table from a column the best way is to use SQL.
Lets say the ADO control is named is dat1.So the SQL looks something like this 

dat1.RecordSource = "SELECT * FROM Table1 WHERE ID LIKE  '" & Text9.Text &"%'"      
dat1.Refresh
dat1.Caption = dat1.RecordSource

here 'Table1' is name of the table from where one want to search data,'ID' is the name of the column and 'Text9' is the name of the text box.The data entered in the  Text9 text box will be the search input.
I have used wildcard.For MS Access '&' is used as a wildcard.
This is the MS Access database table that i have connected to my VB project and from whare i want to search for data.
This is the application that search the ID and gives the relevant data.
 
GOOD LUCK!