Hi Members
Its the first time iam writing in this forum ,iam a new member from TANZANIA
I want to design the LIBRARY MANAGEMENT SYSTEM using VISUAL BASIC 6.0
Can you help me to wite the code for SARCHING BOOKS WHICH ARE STORED IN MY DATABASE AND RETRIEVE IN A LIST BOOK
Thanks

here is a sample search snippet just only for you.....
check this out.....

btw how are you making your connections? this code uses Microsoft ADO.

make sure you have added the followings before try this code :-
Microsoft Activex Data Objects <Version No.> Library
(from Project-->References)
Microsoft Windows Common Controls 6.0
(from Project-->Components)

on your form draw a command button (command1) and a listview control (listview1). configure the listview control accordingly.

create an access database as follows :-
Database Name : books
Database Location : App.Path (same folder as your project)
Table Name : books
Fields : book_id, name, author

Option Explicit

Dim gcn As New ADODB.Connection

Private Sub Command1_Click()
Dim str As String
Dim rs As New ADODB.Recordset
Dim li As ListItem

ListView1.ListItems.Clear

str = "select * from books order by book_id"
rs.CursorLocation = adUseClient
rs.CursorType = adOpenDynamic
rs.LockType = adLockOptimistic
rs.Open str, gcn, adOpenDynamic, adLockOptimistic

If rs.RecordCount > 0 Then
    rs.MoveFirst
    While Not rs.EOF()
        With ListView1
            Set li = .ListItems.Add(, , (rs!book_id))
            li.SubItems(1) = rs!Name
            li.SubItems(2) = rs!author
        End With
        rs.MoveNext
    Wend
End If

If rs.State = adStateOpen Then rs.Close
Set rs = Nothing
End Sub

Private Sub Form_Load()
Dim str As String

str = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & App.Path & "\books.mdb;Persist Security Info=False"
gcn.ConnectionString = str
gcn.Open
End Sub

don't forget to give me your feedback.

regards
Shouvik

1. Hi Belo...Welcome to Daniweb Friend
2. Table Name, Column Name in database ??
3. Post your code first (your attempt code).
Actually Shouvik was given the answer.
Hope you will learn and repost your feedback.

This article has been dead for over six months. Start a new discussion instead.