-1

can you please help me in vb6.

The program is like this:
In the program you want to search a name in the databse. In order to do that you must enter a value in the textbox and click the search command button.

can you help me guyss!! geezz thank you

6
Contributors
22
Replies
66
Views
6 Years
Discussion Span
Last Post by Jonathan_18
0

Use the following -

Private Sub Command1_Click()

Dim con As ADODB.Connection
Set con = New ADODB.Connection

Dim rsSearch As ADODB.Recordset
Set rsSearch = New ADODB.Recordset

con.Open "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & App.Path & "\MyDatabaseName.MDB;Persist Security Info=False"
    
rsSearch.Open "SELECT * FROM MyTableName WHERE MyField LIKE " & "'" & Text1.Text & "'", con, adOpenStatic, adLockOptimistic
'The LIKE function searches the database fo names that is similar than what you typed in text1...

If rsSearch.EOF = True Or rsSearch.BOF = True Then
    MsgBox "No Record Found"
        Else
    'Do here what you need if the file was found...
End If

rsSearch.Close
con.Close
End Sub
0

there's seem to be an error around this part:

rsSearch.Open "SELECT * FROM MyTableName WHERE MyField LIKE " & "'" & Text1.Text & "'", con, adOpenStatic, adLockOptimistic

my Datbase name is Book List and my Fieldname is Title of Books.

0
con.Open "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & App.Path & "\[Book List].MDB;Persist Security Info=False"

rsSearch.Open "SELECT * FROM MyTableName WHERE [Title of Books] LIKE " & "'" & Text1.Text & "'", con, adOpenStatic, adLockOptimistic

Change the "MyTableName" as well.

0

STill the program says

Object Required in this part

rsSearch.Open "SELECT * FROM Books WHERE [Title of Books] LIKE " & "'" & Text1.Text & "'", con, adOpenStatic, adLockOptimistic

0

It is looking for the data active x object library. Did you reference it?

Top menu -

Project/references/MS Active X Data Objects 2.x (x is the version on your pc)

0

In vb6, go to the top menu.
Click on Project
In the list, click on References
When the reference dialog list opens, select "Microsoft Active X Data Objects 2.8"
Click on OK

Now test the code again.:)

0

Please post soon, I need to go offline in the next half hour. I would like to solve your problem before then.:)

0

I think I have a complication with my MSDN, that's why the projrct>reference>MS ACTIVE X DATA onjects" are not running

0

Ok, what version of VB6 do you have, enterprise, professional etc?

Can you see the "project/references" menu?

0

I have a problem at the back-end which is the MSDN..but the code is alright I think

0

I then hope you find a solution to get the data objects sorted soon. Happy coding:)

Please mark this as solved (found at the bottom of this page), as the original question was answered, thanks.:)

0

@tin1296, please mark this thread as solved if you have managed to get a solution, found at the bottom of this page, thanks.:)

It has been open for some time now.

0

hi i read this thread and it help me a lot with my school project..but it would help me more if you'll help me with the Do Statement..i want to display the results..how will i do it??

0

hi i read this thread and it help me a lot with my school project..but it would help me more if you'll help me with the Do Statement..i want to display the results..how will i do it??

Attachments Untitled.png 4.84 KB
0
Dim Search as string
Search = text1.text
'First, input your Connection string from your database then in the Recordset
'Use this code
RS.Open "Select * from YourTable where FirstName like '" & Search & "%'", DB, 3, 3
Do Until RS.EOF
    Rs.Movenext
    MsgBox "Found"
Loop
0

Via using the select query from above (shown below), how would you write an update database command in this format?

rsSearch.Open "SELECT * FROM MyTableName WHERE MyField LIKE " & "'" & Text1.Text & "'", con, adOpenStatic, adLockOptimistic

0

Via using the select query from above (shown below), how would you write an update database command in this format?

rsSearch.Open "SELECT * FROM MyTableName WHERE MyField LIKE " & "'" & Text1.Text & "'", con, adOpenStatic, adLockOptimistic

I've been using rsSearch.Open "UPDATE [TableName] SET [Field2] = " & "'" & "[Value from VB6]" & "'" WHERE [Field1] = & "'" & [Value from VB6]" & "'", con, adOpenKeyset, adLockOptimistic

I'm getting a compile error Expected: end of statement message box, where it highlights the term WHERE

Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.