Connecting to MS Access database

  • Thread starter Thread starter Rob Slabbekoorn
  • Start date Start date
R

Rob Slabbekoorn

Guest
Hi,

I'm trying to connect to a database on my network. When I make a copy of the Access file to a local machine it works fine. But in my network I get the message that no OLE DB-provider is set as provider to the connectionstring. But there is as you can notice in my code. Any idea what this problem can couse and of course do you have a solution?

Kind regards,


Rob

Imports System.Data.OleDb
Public Class Form1
Public con As New OleDb.OleDbConnection
Public cm As New OleDb.OleDbCommand
Public dr As OleDbDataReader
Dim ds As New DataSet
Dim inc As Integer
Dim MaxRows As Integer
Private mdwfile As String

Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
'LADEN
Dim dbProvider As String
Dim dbSource As String
Dim mdb As String
Dim da As New OleDbDataAdapter

dbProvider = "Microsoft.ACE.OLEDB.12.0;"
dbSource = "SQLOLEDB;Data Source = G:\Systeembeheer\Projecten\STP Offerte\Prosfora.accdb;Persist Security Info=False;"
con.ConnectionString = dbProvider & dbSource
con.Open()

If con.State = ConnectionState.Open Then
MsgBox("Connected")
Else
MsgBox("Not Connected!")
End If

Try
mdb = "SELECT * FROM nawbes where NAW_RELNR = '" + TextBox1.Text + "'"
da = New OleDb.OleDbDataAdapter(mdb, con)
da.Fill(ds, "ProsforaDataset")
con.Close()
inc = -1

If ("NAW_RELNR").ToString = TextBox1.Text Then
TextBox2.Text = ("NAW_VOORLETTERS").ToString() + " " + ("NAW_VOORVOEGSELS").ToString() + " " + ("NAW_NAAM").ToString()
TextBox3.Text = ("NAW_STRAAT").ToString() + " " + ("NAW_HUISNUMMER").ToString() + " " + ("NAW_ADRES_TOEVOEGING").ToString()
TextBox4.Text = ("NAW_POSTCODE").ToString()
TextBox5.Text = ("NAW_PLAATS").ToString()
End If
con.Open()

Catch ex As Exception
MsgBox(ex.ToString())
Finally
MsgBox("Dit nummer bestaat niet")
End Try

con.Close()
End Sub

Continue reading...
 
Back
Top