View Full Version : Need help with vb connection string
arian29
18-08-2008, 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")
Charan
18-08-2008, 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
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.
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
arian29
20-08-2008, 11:15 PM
i did that but its still not working :( , its for vb6
Charan
20-08-2008, 11:22 PM
if possible post the source where you are getting the error. post a screen shot if possible.
arian29
23-08-2008, 04:59 PM
now i am getting "object required"
Charan
23-08-2008, 05:44 PM
^^ check your PM
arian29
24-08-2008, 03:24 PM
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"
Charan
24-08-2008, 05:32 PM
Dude, Replace you code with this one. It should work.
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
arian29
25-08-2008, 10:12 PM
Dude, Replace you code with this one. It should work.
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
am getting "User-Defined type not defined"
Charan
02-09-2008, 01: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.
vBulletin® v3.7.0, Copyright ©2000-2009, Jelsoft Enterprises Ltd.