|
dev
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
connectionstring problemI 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 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 > 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 >> > > Check out Settings.settings file located in Properties folder.
The default values are reflected in app.config (yourappname.exe.config file). -- Show quoteMiha 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 > 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 >> > > "Fanor" <xreed2***@yahoo.com> wrote in message I would add the mydbase.mdb file to the project (Add->Existing item etc.) 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???? [] 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 |
|||||||||||||||||||||||