Ms Access: "Provider Microsoft - Jet.Oledb.4.0Datasource D:/Mydata - MDB "
Ms Access: "Provider Microsoft - Jet.Oledb.4.0Datasource D:/Mydata - MDB "
Imports System.Data.Odbc
Dim con As New OdbcConnection("DSN=yoh;")
Dim cmd As New OdbcCommand
Public neym As String
Public Sub New()
con.Open()
cmd.Connection = con
cmd.CommandText = "SELECT * FROM table1"
End Sub
Public Sub creates()
cmd.CommandText = "INSERT INTO table1(Neyms) VALUES('" + neym + "')"
cmd.ExecuteNonQuery()
End Sub
Imports System.Data.Oledb
Dim con As New
OledbConnection("Provider=microsoft.Jet.oledb.4.0DataSource=D:\mydata.mdb;")
Dim cmd As New OledbCommand
Public var1 As String
Public Sub New()
con.Open()
cmd.Connection = con
cmd.CommandText = "SELECT * FROM table1"
End Sub
Public Sub creates()
cmd.CommandText = "INSERT INTO table1(Neyms) VALUES('" + var1 + "')"
cmd.ExecuteNonQuery()
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=Microsoft.Jet.OLEDB.4.0;Data
Source=TestDatabase.mdb;"
Dim ds As New DataSet
Dim cnn As OleDbConnection = New OleDbConnection(MDBConnString_)
cnn.Open()
Dim cmd As New OleDbCommand(query, cnn)
Dim da As New OleDbDataAdapter(cmd)
da.Fill(ds, Table_)
cnn.Close()
Dim t1 As DataTable = ds.Tables(Table_)
Dim row As DataRow
Dim Item(2) As String
For Each row In t1.Rows
Item(0) = row(0)
Item(1) = row(1)
Dim NextListItem As New ListViewItem(Item)
ListView1.Items.Add(NextListItem)
Next
Dim sDBPassword as String
Dim oDBEngine As DAO.DBEngine
Dim oDB As DAO.Database
sDBPassword = "Mypassword" 'database password
oDBEngine = oAccess.DBEngine
oDB = oDBEngine.OpenDatabase(Name:=sDBPath, _
Options:=False, _
ReadOnly:=False, _
Connect:=";PWD=" & sDBPassword)
oAccess.OpenCurrentDatabase(filepath:=sDBPath, _
Exclusive:=False)
oDB.Close()
System.Runtime.InteropServices.Marshal.ReleaseComObject(oDB)
oDB = Nothing
System.Runtime.InteropServices.Marshal.ReleaseComObject(oDBEngine)
oDBEngine = Nothing