Having trouble in visual basic 6.0 programming

Asked By 0 points N/A Posted on -
qa-featured

I am new in learning visual basic 6.0 and I'm having trouble coding a search function in VB6.0. I want the program to let the user enter a data in search textbox and then it will filter the data by the first string of the input and display all the filtered data in a datagrid.

example:

the user typed A, all of the data in my database that is starting with the letter A will appear in the datagrid.

Please show me some codes for this.

 

SHARE
Answered By 0 points N/A #101883

Having trouble in visual basic 6.0 programming

qa-featured

 

Private Sub Command1_Click()
Dim con As New ADODB.Connection
Dim rs As New ADODB.Recordset
con.ConnectionString = "Enter the database connection String"
con.Open
Set rs = con.Execute ("select * from tablename where ucase ( col1 ) like 'A%' or ucase ( col2 ) like 'A%' or ucase ( col3 ) like 'A%'")
DataGrid1.DataSource = rs
End Sub
 
Since you have a database, why do not you use an SQL query,. Just create the connection and execute the query for the results. the result should give certain rows where entries start with A. Enter the connection string, namely, servername, username, password, RD/RW etc.
Enter the table name of the data residing in. list the coloumns in the table as col1, col2, col3 etc.
This may create a problem that the system may start working slow as a huge amount of data from the grid is being replaced from the database, mostly problematic when with multiuser system
Thanks.

Related Questions