' เพิ่ม reference ชื่อ Microsoft ActiveX Data Objects 2.0 Library
' http://www.expert2you.com/article1/2093/index.htm?page_no=1
' http://www.thaiio.com/cgi-bin/html/vhtml.pl?name=iotoday&topic=25
Private Sub Form_Load()
Set cn = New ADODB.Connection
cn.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & App.Path & "/Nwind.mdb;"
cn.Open
Dim sqlString As String
Dim rs As ADODB.Recordset
Set rs = New ADODB.Recordset
rs.Open "select * from categories", cn
txt = ""
rs.Requery
Do While Not rs.EOF
txt = txt & rs.Fields("categoryid") & " " & rs.Fields("categoryname") & Chr(13)
rs.MoveNext
Loop
MsgBox txt
End Sub
|