Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Connection string help 2

Status
Not open for further replies.

EchoAlertcom

IS-IT--Management
Oct 8, 2002
239
0
0
US
Hello,

I am using the ADODC and I would like to use a connection string that uses the App.Path but I am unsuccessful so far.

I have removed the ConnectionString value from the Properties box. and added to my code:

Code:
datPrimaryRS.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & App.Path & "\passwordpal.mdb;Persist Security Info=False"

But gives me the error of:

"Data source name not found and no default driver specified"

I'm not using a DSN -- ALSO >
It works fine when I use:
Code:
datPrimaryRS.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=c:\program files\Password Pal\passwordpal.mdb;Persist Security Info=False"

I appreciate any help.

Thank you.
Steve Funk
 
You probably need to just put quotes after the password.pal name and add &. Like this :

datPrimaryRS.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & App.Path & "\passwordpal.mdb" & ";Persist Security Info=False"

I know it may seem like it's saying the same thing, but in my experience, cometimes VB gets a little confused over the simple things.
 
I tried that but it I got the same results. Any other suggestions?

Thank you for the help.

Sincerely,
Steve
 
Did you try setting the App.Path and the file name to a string variable and then inserting it into the connection string? May be worth a try. If you choose to battle wits with the witless be prepared to lose.

[cheers]
 
Are you getting this error while in design mode, if so app.path is where your project is located.
 
IS the database in the same folder as your project?

Transcend
[gorgeous]
 
Hi,

Yes the database is in the same folder as my project.

I appreciate everyone's suggestions.

Sincerelty,
Steve
 
If you do this -> msgbox app.path
you should see c:\program files\Password Pal
My guess is you don't.
 
Actually, when i did a msgbox the path WAS correct.

AND, when I put the path in the Properties without the App.Path it works

BUT, when I remove it from the ConnectionString properties from the property box and put

datPrimaryRS.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=c:\program files\Password Pal\passwordpal.mdb;Persist Security Info=False"

in my code it doesn't work. Could the problem be how or when I am writing this in code?

The only time I use the ADODC is in the Form Load sub. And I have the datPrimaryRS.ConnectionString ..." before any other code in the Form Load sub.

I hope this sheds some light on where I'm goofing up.

Sincerely,
Steve
 
I know, you must have a datagrid or something's datasource property set to datPrimaryRS in the properties windows. If so delete this and set it in code.

Something like this:

datPrimaryRS.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=c:\program files\Password Pal\passwordpal.mdb;Persist Security Info=False"

Set DataGrid1.DataSource = datPrimaryRS
 
The only things you have to do is:

1. Remove the RecordSource from the properties window and set it in code.

This will get rid of the error.
Actually, you should copy it before removing it because you will need it below.

2. Right after setting the connection string use:

Adodc1.RecordSource = "SELECT * FROM SomeTable"
Adodc1.Refresh

 
Moving the RecordSoure into code worked..

Thanks to everyone for your help.

Sincerely,
Steve
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top