DIGIT-ARC read-only archive · snapshot: July 23, 2026

Need help with vb connection string

10 posts · originally from https://geek.digit.in/community/threads/need-help-with-vb-connection-string.95850/

A
arian29 Original post #1
Aug 18, 2008 at 12:03 AM
can someone please help me with the code below, i am getting error "Expected )"

con.Provider = ("Microsoft.Jet.OLEDB.4.0;data source = " & App.Path & "\" & "vbox.mdb";Jet OLEDB:Database Password=qw34;Persist Security Info=False")
RCuber
RCuber #2
Aug 18, 2008 at 12:34 AM
can someone please help me with the code below, i am getting error "Expected )"

con.Provider = ("Microsoft.Jet.OLEDB.4.0;data source = " & App.Path & "\" & "vbox.mdb";Jet OLEDB:Database Password=qw34;Persist Security Info=False")
Is it VB 6 or VB.NET? I dont see any problem in the code.

If its VB.NET then you cannot assign the the Provider property as its readonly. Try like this
Code:
Dim ConnectionString As String = String.Empty
Dim WorkingDirectory As String = String.Empty
Dim DataBaseFile As String = String.Empty

WorkingDirectory = System.Environment.CurrentDirectory & "\"
DataBaseFile = WorkingDirectory & "\" & "vbox.mdb"
ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & DataBaseFile & ";User ID=;Jet OLEDB:Database Password=qw34;"

Dim Con as New OleDBConnection ( ConnectionString )

If its VB 6 then try like this.

Code:
Dim ConnectionString As String = ""
Dim WorkingDirectory As String = ""
Dim DataBaseFile As String = "" 
Dim Con As ADODB.Connection

WorkingDirectory = App.Path & "\"
DataBaseFile = WorkingDirectory & "vbox.mdb"
ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & DataBaseFile & ";User Id=admin;Password=qw34;"
Set Con = New ADODB.Connection
Con.Open ConnectionString
A
arian29 #3
Aug 20, 2008 at 11:15 PM
i did that but its still not working :( , its for vb6
RCuber
RCuber #4
Aug 20, 2008 at 11:22 PM
if possible post the source where you are getting the error. post a screen shot if possible.
A
arian29 #5
Aug 23, 2008 at 4:59 PM
[FONT=Verdana, Arial, Helvetica][FONT=Verdana, Arial, Helvetica] now i am getting "object required"[/FONT][/FONT]
RCuber
RCuber #6
Aug 23, 2008 at 5:44 PM
^^ check your PM
A
arian29 #7
Aug 24, 2008 at 3:24 PM
[FONT=Verdana, Arial, Helvetica][FONT=Verdana, Arial, Helvetica] Private Sub CommandButton1_Click()

Set con = CreateObject("ADODB.connection")
Set rs = CreateObject("ADODB.recordset")
Set cmd = CreateObject("ADODB.command")
con.Provider = ("Microsoft.Jet.OLEDB.4.0;Jet OLEDB:Database Password=asd123;data source = " & App.Path & "\" & "vbox_db.mdb;Persist Security Info=False")
con.Open App.Path & "\vbox_db.mdb"
[/FONT][/FONT]
RCuber
RCuber #8
Aug 24, 2008 at 5:32 PM
Dude, Replace you code with this one. It should work.
Code:
Private Sub CommandButton1_Click()
Dim ConnectionString As String = ""
Dim WorkingDirectory As String = ""
Dim DataBaseFile As String = "" 
Dim Con As ADODB.Connection

WorkingDirectory = App.Path & "\"
DataBaseFile = WorkingDirectory & "vbox.mdb"
ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & DataBaseFile & ";User Id=admin;Password=qw34;"
Set Con = New ADODB.Connection
Con.Open ConnectionString
.
.
.

End Sub
A
arian29 #9
Aug 25, 2008 at 10:12 PM
Dude, Replace you code with this one. It should work.
Code:
Private Sub CommandButton1_Click()
Dim ConnectionString As String = ""
Dim WorkingDirectory As String = ""
Dim DataBaseFile As String = "" 
Dim [COLOR=Red][B]Con As ADODB.Connection[/B][/COLOR]

WorkingDirectory = App.Path & "\"
DataBaseFile = WorkingDirectory & "vbox.mdb"
ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & DataBaseFile & ";User Id=admin;Password=qw34;"
Set Con = New ADODB.Connection
Con.Open ConnectionString
.
.
.

End Sub
am getting "User-Defined type not defined"
RCuber
RCuber #10
Sep 2, 2008 at 1:55 PM
Sorry for the delay .. I missed this thread.You get this error because you havent added a reference to ado in your project. Please add a reference to "Microsoft ActiveX Data Objects Library" and this should work.