| | |
want to populate the listbox with msaccess database table data
Please support our Visual Basic 4 / 5 / 6 advertiser: Programming Forums - DaniWeb Sister Site
![]() |
•
•
Join Date: Dec 2008
Posts: 21
Reputation:
Solved Threads: 0
hi there, i have a form in Vb6 and a msacess 2007 database connected using ADODC, on a form is a listbox that i want to populate with the table data from the database, the name of the database is Storenw and the table from which i want to access is sales with fields barcode,item and price. i have the following code in my form-load seem to be working because am not getting any error but in the listbox is showing nothing,.. what can i do? am new in this pls!
code:
Private Sub Form_Load()
Dim rs As New ADODB.Recordset
Dim strConnectionString As String
Dim strSQL As String
On Error GoTo Handler:
strConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;" _
& "Data Source=C:\Documents and Settings\Mateuss\My Documents\project\storenw.mdb;Persist Security Info=False"
strSQL = "select * from sales"
rs.Open strSQL, strConnectionString
If Not (rs.EOF And rs.BOF) Then
rs.MoveFirst
Do While Not rs.EOF
barcode = rs.Fields(0).Value
item = rs.Fields(1).Value
price = rs.Fields(2).Value
Call AddToListBox(barcode, item, price)
rs.MoveNext
Loop
Else
MsgBox "Nothing found."
End If
My_Exit_Sub:
On Error Resume Next
rs.Close
Set rs = Nothing
Exit Sub
Handler:
MsgBox "Error " & Err.Number & ": " & Err.Description
Resume My_Exit_Sub
End Sub
Private Sub AddToListBox(ByVal barcode As String, ByVal item As String, ByVal price As String)
End Sub
code:
Private Sub Form_Load()
Dim rs As New ADODB.Recordset
Dim strConnectionString As String
Dim strSQL As String
On Error GoTo Handler:
strConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;" _
& "Data Source=C:\Documents and Settings\Mateuss\My Documents\project\storenw.mdb;Persist Security Info=False"
strSQL = "select * from sales"
rs.Open strSQL, strConnectionString
If Not (rs.EOF And rs.BOF) Then
rs.MoveFirst
Do While Not rs.EOF
barcode = rs.Fields(0).Value
item = rs.Fields(1).Value
price = rs.Fields(2).Value
Call AddToListBox(barcode, item, price)
rs.MoveNext
Loop
Else
MsgBox "Nothing found."
End If
My_Exit_Sub:
On Error Resume Next
rs.Close
Set rs = Nothing
Exit Sub
Handler:
MsgBox "Error " & Err.Number & ": " & Err.Description
Resume My_Exit_Sub
End Sub
Private Sub AddToListBox(ByVal barcode As String, ByVal item As String, ByVal price As String)
End Sub
it seems your AddToListBox procedure doesn't do anything.
vb Syntax (Toggle Plain Text)
Private Sub AddToListBox(ByVal barcode As String, ByVal item As String, ByVal price As String) list1.additem(barcode & " " & item & " " & price) End Sub
![]() |
Other Threads in the Visual Basic 4 / 5 / 6 Forum
- Previous Thread: Userprofile
- Next Thread: Search a particular file
| Thread Tools | Search this Thread |
* 6 429 2007 access activex add age application basic beginner birth bmp calculator cd cells.find click client code college column component connection connectionproblemusingvb6usingoledb copy creat ctrl+f data database datareport date delete dissertations dissertationthesis dissertationtopic edit error excel excelmacro file filename form hardware header iamthwee image inboxinvb internetfiledownload keypress label listbox listview liveperson login looping machine microsoft movingranges number objectinsert open oracle password prime program prompt range-objects readfile reading record refresh remotesqlserverdatabase report retrieve save search sendbyte sites sort sql sql2008 sqlserver subroutine tags textbox time urldownloadtofile vb vb6 vb6.0 vba visual visualbasic visualbasic6 web window windows






