i am trying to coonect ms access with vb6. The code is working but after i execute "SELECT * from table" it is showing the content for the last row in the ms access. I am wondering how i can change my code so it display all the content instead of jst the last row. Here is my code:

Private Sub Command1_Click()
Dim DB_ACCESS As Database
Dim recset As Recordset
Dim connString As String
Dim bdName As String
Dim sqlString As String

connString = "ODBC;DSN=" & dbName & "UID=" & "" & ";PWD=" & "" & _
        ";DATABASE=" & bdName

Set DB_ACCESS = OpenDatabase(App.Path & "\db1.mdb")

sqlString = "SELECT * FROM table1"

Set recset = DB_ACCESS.OpenRecordset(sqlString, dbOpenDynaset)

Text1.Text = recset.Fields(0) & " " & recset.Fields(1) & " " & recset.Fields(2)

End Sub

sorry , i had made a mistake it is actually showing the 1st record (1st row).

Hi,
You r in first record. u have to iterate all the records. Be sure to set TextBox's Multiline property to true and Set Scroll bar property in design time.

Code to Iterate

recset.MoveFirst
  Dim sRow as String 
  Text1.Text = ""

  Do While Not recset.EOF
     sRow = recset.Fields(0) & " " & recset.Fields(1) & " " & recset.Fields(2) 
     recset.MoveNext
     Text1.Text = Text1.Text & sRow & vbCrLf
  Loop

Instead of

Text1.Text = recset.Fields(0) & " " & recset.Fields(1) & " " & recset.Fields(2)

Hi,

To Show all the Records from the Table, you need to use a Table like Control.. eg.:DataGrid or FlexGrid or VFlexGrid..

Texbox, has a Limit and it is not appropriate and readable to show Table like structures..

Regards
Veena

Really thanks for all the helps...i will try to figure out how 2 code them in ms flexgrid :)

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