How can I display a MS Access db in VB.NET?
Printable View
How can I display a MS Access db in VB.NET?
vb_Tux,
the answer to that question has filled many books in bookstores around the world.
can you be more specific? like, do you wish to connect to an access db? add records? delete, update records? reports? grids?
I have a .mdb file, how would I go about getting the contents of that? (displaying it into a data grid to be specific)
VB Code:
'Create DataSet (thru adapter fill ds from table) Imports System.Data.Oledb Public Class Form1 Inherits System.Windows.Forms.Form 'form level declarations Dim cn As OleDbConnection Dim sConn As String Dim ds As DataSet Dim da As OleDbDataAdapter Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load Dim sDBNAme As String = "c:\TestDB\TestDB.mdb" Dim sSQL As String = "select * from PRQ" sConn = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & sDBNAme & ";Persist Security Info=False" cn = New OleDbConnection(sConn) ds = New DataSet() da = New OleDbDataAdapter(sSQL, cn) da.Fill(ds, "TableName") 'Bind dataGrid to DataSet dg.DataSource = ds.Tables("TableName") 'Clean memory (Like Setting to Nothing) ds.Dispose() da.Dispose() End Sub End CLass
Oh thanks :D Your solved my problem, although I feel I hi-jacked vb_TuX's thread :D
That example is pretty good for beginners, thanks Iouri!