Forum     

Go Back   Digit Technology Discussion Forum > Software > Programming
Register FAQ Calendar Mark Forums Read

Programming The destination for developers - C, C++, Java, Python and the lot


Closed Thread
 
LinkBack Thread Tools Display Modes
Old 18-08-2008, 12:03 AM   #1 (permalink)
In The Zone
 
arian29's Avatar
 
Join Date: Feb 2008
Location: New Delhi
Posts: 212
Arrow Need help with vb connection string


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 OLEDBatabase Password=qw34;Persist Security Info=False")
arian29 is offline  
Advertisements. Register and be a member of the community to get rid of them.
Advertisement

Old 18-08-2008, 12:34 AM   #2 (permalink)
Rubik's Uncle!!
 
Charan's Avatar
 
Join Date: Sep 2004
Location: ಬೆಂಗಳೂರು (Bengaluru)
Posts: 3,785
Default Re: Need help with vb connection string

Quote:
Originally Posted by arian29 View Post
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 OLEDBatabase 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
__________________
i5 2400 | DH67BL | G.Skill Ripjaw 4 GB | FSP SAGA II 500W | CM 430 Black Elite | MSI R6850 Cyclone PE/OC | XBox 360 Controller | 21.5" Samsung Sync Master 2233 | 4 Mbps @75GB FUP :)
Battlefield 3 Multiplayer Discussion | Battlefield 3 Low Latency Servers List
Charan is online now  
Old 20-08-2008, 11:15 PM   #3 (permalink)
In The Zone
 
arian29's Avatar
 
Join Date: Feb 2008
Location: New Delhi
Posts: 212
Default Re: Need help with vb connection string

i did that but its still not working , its for vb6
arian29 is offline  
Old 20-08-2008, 11:22 PM   #4 (permalink)
Rubik's Uncle!!
 
Charan's Avatar
 
Join Date: Sep 2004
Location: ಬೆಂಗಳೂರು (Bengaluru)
Posts: 3,785
Default Re: Need help with vb connection string

if possible post the source where you are getting the error. post a screen shot if possible.
__________________
i5 2400 | DH67BL | G.Skill Ripjaw 4 GB | FSP SAGA II 500W | CM 430 Black Elite | MSI R6850 Cyclone PE/OC | XBox 360 Controller | 21.5" Samsung Sync Master 2233 | 4 Mbps @75GB FUP :)
Battlefield 3 Multiplayer Discussion | Battlefield 3 Low Latency Servers List
Charan is online now  
Old 23-08-2008, 04:59 PM   #5 (permalink)
In The Zone
 
arian29's Avatar
 
Join Date: Feb 2008
Location: New Delhi
Posts: 212
Default Re: Need help with vb connection string

now i am getting "object required"
arian29 is offline  
Old 23-08-2008, 05:44 PM   #6 (permalink)
Rubik's Uncle!!
 
Charan's Avatar
 
Join Date: Sep 2004
Location: ಬೆಂಗಳೂರು (Bengaluru)
Posts: 3,785
Default Re: Need help with vb connection string

^^ check your PM
__________________
i5 2400 | DH67BL | G.Skill Ripjaw 4 GB | FSP SAGA II 500W | CM 430 Black Elite | MSI R6850 Cyclone PE/OC | XBox 360 Controller | 21.5" Samsung Sync Master 2233 | 4 Mbps @75GB FUP :)
Battlefield 3 Multiplayer Discussion | Battlefield 3 Low Latency Servers List
Charan is online now  
Old 24-08-2008, 03:24 PM   #7 (permalink)
In The Zone
 
arian29's Avatar
 
Join Date: Feb 2008
Location: New Delhi
Posts: 212
Default Re: Need help with vb connection string

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 OLEDBatabase Password=asd123;data source = " & App.Path & "\" & "vbox_db.mdb;Persist Security Info=False")
con.Open App.Path & "\vbox_db.mdb"
arian29 is offline  
Old 24-08-2008, 05:32 PM   #8 (permalink)
Rubik's Uncle!!
 
Charan's Avatar
 
Join Date: Sep 2004
Location: ಬೆಂಗಳೂರು (Bengaluru)
Posts: 3,785
Default Re: Need help with vb connection string

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
__________________
i5 2400 | DH67BL | G.Skill Ripjaw 4 GB | FSP SAGA II 500W | CM 430 Black Elite | MSI R6850 Cyclone PE/OC | XBox 360 Controller | 21.5" Samsung Sync Master 2233 | 4 Mbps @75GB FUP :)
Battlefield 3 Multiplayer Discussion | Battlefield 3 Low Latency Servers List
Charan is online now  
Old 25-08-2008, 10:12 PM   #9 (permalink)
In The Zone
 
arian29's Avatar
 
Join Date: Feb 2008
Location: New Delhi
Posts: 212
Default Re: Need help with vb connection string

Quote:
Originally Posted by Charan View Post
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
am getting "User-Defined type not defined"
arian29 is offline  
Old 02-09-2008, 01:55 PM   #10 (permalink)
Rubik's Uncle!!
 
Charan's Avatar
 
Join Date: Sep 2004
Location: ಬೆಂಗಳೂರು (Bengaluru)
Posts: 3,785
Default Re: Need help with vb connection string

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.
__________________
i5 2400 | DH67BL | G.Skill Ripjaw 4 GB | FSP SAGA II 500W | CM 430 Black Elite | MSI R6850 Cyclone PE/OC | XBox 360 Controller | 21.5" Samsung Sync Master 2233 | 4 Mbps @75GB FUP :)
Battlefield 3 Multiplayer Discussion | Battlefield 3 Low Latency Servers List
Charan is online now  
Closed Thread

Bookmarks

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
String.replace estranged12 Programming 2 09-04-2008 09:58 AM
C++ String to all conversion.... Help needed... aditya.shevade Programming 8 06-03-2008 11:33 PM
how to make the string function ? clmlbx Programming 3 25-02-2008 09:43 PM
cant declare a string variable... geekgod Open Source 13 12-08-2006 06:09 AM
asp 'replace' string query! 144 QnA (read only) 1 30-06-2006 10:35 AM

 
Latest Threads
- by Sujeet
- by clmlbx
- by Sujeet
- by icebags

Advertisement




All times are GMT +5.5. The time now is 11:10 AM.


Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2012, vBulletin Solutions, Inc.

Search Engine Optimization by vBSEO 3.3.2