First you have to add reference with "ADODB".Click "project > Add reference" Select "adodb" on .net tab.
This is the example code for using MS accesss databaseand we assumed the Database named "Database1",with table named "Tabletest" and the column named "Test".
Make One form and one label on it.
Write this code:
'First code write at top
Dim Conn As New ADODB.Connection
Dim Rec As New ADODB.Recordset
'Second code Write at Form Load Code
Conn.ConnectionString = "Provider=Microsoft.ACE.OLEDB.12.0;Data source= Path of your database\Database1.accdb"
Conn.Open()
Rec.Open("SELECT * FROM Table1", Conn, ADODB.CursorTypeEnum.adOpenDynamic, ADODB.LockTypeEnum.adLockOptimistic)
While Not Rec.EOF
Label1.Text = Label1.Text & vbCrLf & Rec.Fields("Test").Value
Rec.MoveNext()
Conn.close()
End While
Friday, March 6, 2009
Subscribe to:
Post Comments (Atom)

No comments:
Post a Comment