Home All Groups Group Topic Archive Search About

connectionstring problem

Author
12 Jun 2006 8:38 PM
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

Author
12 Jun 2006 8:44 PM
Fanor
I forgot to say, that i'm using  C# in a windows form application.

Show quote
"Fanor" <xreed2***@yahoo.com> wrote in message
news:uiwi69ljGHA.4508@TK2MSFTNGP05.phx.gbl...
> 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
>
Author
13 Jun 2006 5:20 AM
Cor Ligthert [MVP]
Fanor,

If you put it in the bin directory than you can use application.startuppath
which is the directory where it is deployed if you use the .msi system of
deployment.

http://msdn2.microsoft.com/en-us/library/system.windows.forms.application.startuppath.aspx

I hope this helps,

Cor



Show quote
"Fanor" <xreed2***@yahoo.com> schreef in bericht
news:e0Rz1AmjGHA.3816@TK2MSFTNGP02.phx.gbl...
>I forgot to say, that i'm using  C# in a windows form application.
>
> "Fanor" <xreed2***@yahoo.com> wrote in message
> news:uiwi69ljGHA.4508@TK2MSFTNGP05.phx.gbl...
>> 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
>>
>
>
Author
13 Jun 2006 8:03 AM
Miha Markic [MVP C#]
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/

Show quote
"Fanor" <xreed2***@yahoo.com> wrote in message
news:uiwi69ljGHA.4508@TK2MSFTNGP05.phx.gbl...
> 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
>
Author
13 Jun 2006 3:18 PM
Fanor
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.


Show quote
"Miha Markic [MVP C#]" <miha at rthand com> wrote in message
news:uIafR$rjGHA.1940@TK2MSFTNGP02.phx.gbl...
> 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" <xreed2***@yahoo.com> wrote in message
> news:uiwi69ljGHA.4508@TK2MSFTNGP05.phx.gbl...
>> 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
>>
>
>
Author
13 Jun 2006 8:20 PM
James Minns
"Fanor" <xreed2***@yahoo.com> wrote in message
news:uiwi69ljGHA.4508@TK2MSFTNGP05.phx.gbl...
> 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

AddThis Social Bookmark Button