connectionstring problem

  • Thread starter Thread starter Fanor
  • Start date Start date
F

Fanor

HI all,

I have in my settings a connection string. When I run in debug mode the
connection string is pointing to

myproj\bin\debug\mydbase.mdb

however mydbase.mdb is in myproj\

From the dsigner i can view the tables, wich means the connection is ok. But
when I run it i got that problem.

I looked for some configuration file in which is defined |directory| ( for
the connection string), but i couldn't find it.

Can someone tell me from where VS2005 takes that value for the connection
string in debug mode????

TIA
 
Check out Settings.settings file located in Properties folder.
The default values are reflected in app.config (yourappname.exe.config
file).
 
The value in that file is :


<add name="PhotoMgr.Properties.Settings.PMConnect"
connectionString="Provider=Microsoft.Jet.OLEDB.4.0;Data
Source=|DataDirectory|\PhotosMgr.mdb"
providerName="System.Data.OleDb" />

As u can see the problem is with |DataDirectory| wich is the place
where the datafile should be. Where |DataDirectory| value is taking from
when i run the program???.
from data source i can view the records in the table, so the connection is
ok. But when i run it, it doesn't work.


Miha Markic said:
Check out Settings.settings file located in Properties folder.
The default values are reflected in app.config (yourappname.exe.config
file).

--
Miha Markic [MVP C#]
RightHand .NET consulting & development www.rthand.com
Blog: http://cs.rthand.com/blogs/blog_with_righthand/

Fanor said:
HI all,

I have in my settings a connection string. When I run in debug mode the
connection string is pointing to

myproj\bin\debug\mydbase.mdb

however mydbase.mdb is in myproj\

From the dsigner i can view the tables, wich means the connection is ok.
But when I run it i got that problem.

I looked for some configuration file in which is defined |directory|
( for the connection string), but i couldn't find it.

Can someone tell me from where VS2005 takes that value for the connection
string in debug mode????

TIA
 
Fanor said:
HI all, []

I looked for some configuration file in which is defined |directory| (
for the connection string), but i couldn't find it.

Can someone tell me from where VS2005 takes that value for the connection
string in debug mode????
[]

I would add the mydbase.mdb file to the project (Add->Existing item etc.)
then specify "Copy to Output": Copy if newer
That way your connection string will contain |DataDirectory| (and I don't
know how it decides that expansion either) but it works...


James
 
Back
Top