0% found this document useful (0 votes)
21 views2 pages

Access Database Connection with OLEDB

The document discusses connecting to and querying an Access database from VB.NET. It includes code to open connections to Access databases using ODBC and OleDb, execute queries to select and insert data, and populate data into a ListView. It also includes code to open an Access database using DAO and provide a password.

Uploaded by

Nanda Kumar
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
21 views2 pages

Access Database Connection with OLEDB

The document discusses connecting to and querying an Access database from VB.NET. It includes code to open connections to Access databases using ODBC and OleDb, execute queries to select and insert data, and populate data into a ListView. It also includes code to open an Access database using DAO and provide a password.

Uploaded by

Nanda Kumar
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd

MS Access

Imports [Link]


Dim con As New OdbcConnection("DSN=yoh;")

Dim cmd As New OdbcCommand

Public neym As String

Public Sub New()
[Link]()

[Link] = con
[Link] = "SELECT * FROM table1"

End Sub

Public Sub creates()
[Link] = "INSERT INTO table1(Neyms) VALUES('" + neym + "')"
[Link]()

End Sub

Imports [Link]


Dim con As New
OledbConnection("Provider=[Link].4.0DataSource=D:\[Link];")

Dim cmd As New OledbCommand

Public var1 As String

Public Sub New()
[Link]()

[Link] = con
[Link] = "SELECT * FROM table1"

End Sub

Public Sub creates()
[Link] = "INSERT INTO table1(Neyms) VALUES('" + var1 + "')"
[Link]()

End Sub

Collapse | Copy Code
Grabs data from a table and posts it into a ListView
Dim Table_ As String = "Table1"
Dim query As String = "SELECT * FROM " & Table_
Dim MDBConnString_ As String = "Provider=[Link].4.0;Data
Source=[Link];"
Dim ds As New DataSet
Dim cnn As OleDbConnection = New OleDbConnection(MDBConnString_)
[Link]()
Dim cmd As New OleDbCommand(query, cnn)
Dim da As New OleDbDataAdapter(cmd)
[Link](ds, Table_)
[Link]()
Dim t1 As DataTable = [Link](Table_)
Dim row As DataRow
Dim Item(2) As String
For Each row In [Link]
Item(0) = row(0)
Item(1) = row(1)
Dim NextListItem As New ListViewItem(Item)
[Link](NextListItem)
Next
Dim sDBPassword as String
Dim oDBEngine As [Link]
Dim oDB As [Link]

sDBPassword = "Mypassword" 'database password
oDBEngine = [Link]
oDB = [Link](Name:=sDBPath, _
Options:=False, _
ReadOnly:=False, _
Connect:=";PWD=" & sDBPassword)
[Link](filepath:=sDBPath, _
Exclusive:=False)
[Link]()
[Link](oDB)
oDB = Nothing
[Link](oDBEngine)
oDBEngine = Nothing

You might also like