feurich Posted November 27, 2003 Posted November 27, 2003 I have a problem with the design time en runtime database folder. When running the exe from the installed application. the application still looks for the database in my design Folder. Does anyone knows what i'm talking about ?? Cire Quote Trust the Universe
Administrators PlausiblyDamp Posted November 27, 2003 Administrators Posted November 27, 2003 How are you refering to the database's path? If you've hard coded an absolute path into the executable then it will look there. You may want to make the connection string a dynamic property if you've used the wizards to generate the connection - this will move it to an app.config file that can easily be editied to point to the correct location. Quote Posting Guidelines FAQ Post Formatting Intellectuals solve problems; geniuses prevent them. -- Albert Einstein
feurich Posted November 28, 2003 Author Posted November 28, 2003 OK BUT OK I understand but how does this work when you make a setup of the application and want to install it on a other computer? Does the app.config file gets modified during setup(automatically) or do you have to write an installation script for that? Cire :-\ Quote Trust the Universe
Mehyar Posted November 28, 2003 Posted November 28, 2003 What you can do is use Application.StartupPath instead of the absolute path and place the database in your bin folder. It will automatically be included in your setup. Quote Dream as if you'll live forever, live as if you'll die today
fadi Posted November 28, 2003 Posted November 28, 2003 the idea is that the path u write should be relative to the exe running Quote
feurich Posted November 28, 2003 Author Posted November 28, 2003 The path in my application is relative i wrote: Public Function GetAppPath() As String '*** Get the path where the application has been launched. Dim sPath As String Try sPath = System.Reflection.Assembly.GetExecutingAssembly.Location sPath = Left(sPath, InStrRev(sPath, "\", -1, CompareMethod.Text)) Return sPath Catch ex As Exception MsgBox(ex.Message, MsgBoxStyle.Critical, g_AppConstants.MsgCaption) End Try End Function but when i make a setup of the application the design path is still in the OleDbconnection Object. I didn't use the dynamic connection string yet. Does it mean that when you use the dynamic connectionstring the OleDBconnectionstrings wil be the relative path that i use in the startup module of my application? Cire Quote Trust the Universe
fadi Posted November 28, 2003 Posted November 28, 2003 instead of your code u can write return application.startuppath Quote
feurich Posted November 28, 2003 Author Posted November 28, 2003 That's a little bit easier OK you code looks a lot easier . But any answers on the rest of the questions? Quote Trust the Universe
fadi Posted November 28, 2003 Posted November 28, 2003 well i've not used ur way before,so i dont know Quote
feurich Posted November 28, 2003 Author Posted November 28, 2003 Actual question is ... My Actual question is : How can I make a setup of the project I have that doesn't store the connectionstring(with the database source path in it )in the connection object? I have tried it with the dynamic connection string but then i get a serious error when i run the setup on an other machine. Cire Quote Trust the Universe
Moderators Robby Posted November 29, 2003 Moderators Posted November 29, 2003 What does your dynamic connection string look like? Quote Visit...Bassic Software
feurich Posted November 29, 2003 Author Posted November 29, 2003 2 ways Well I tried it two ways. 1) By using the wizard to make the connection to the Acces database. In this situation the connection string is stored in the connection object like :see the attached file.objectconstring.bmp Quote Trust the Universe
feurich Posted November 29, 2003 Author Posted November 29, 2003 (edited) 2 ways more.. The other way I tried was with a dynamic connection string in th4eapp.config file. Here I got a very seriuos error. For the connection string see the attached file. And here is the content of the app.config file. <?xml version="1.0" encoding="utf-8"?> <configuration> <appSettings> <!-- User application and configured property settings go here.--> <!-- Example: <add key="settingName" value="settingValue"/> --> <add key="DBConIDX.ConnectionString" value="Jet OLEDB:Global Partial Bulk Ops=2;Jet OLEDB:Registry Path=;Jet OLEDB:Database Locking Mode=1;Data Source="c:\Program Files\Printbarcode\BarcodeDB.mdb";Jet OLEDB:Engine Type=5;Provider="Microsoft.Jet.OLEDB.4.0";Jet OLEDB:System database=;Jet OLEDB:SFP=False;persist security info=False;Extended Properties=;Mode=Share Deny None;Jet OLEDB:Encrypt Database=False;Jet OLEDB:Create System Database=False;Jet OLEDB:Don't Copy Locale on Compact=False;Jet OLEDB:Compact Without Replica Repair=False;User ID=Admin;Jet OLEDB:Global Bulk Transactions=1" /> <add key="OleDbConnection1.ConnectionString" value="Jet OLEDB:Global Partial Bulk Ops=2;Jet OLEDB:Registry Path=;Jet OLEDB:Database Locking Mode=1;Data Source="F:\Projects\.Net Projects\Print Barcode\Print Barcode\Print Barcode\bin\BarcodeDB.mdb";Jet OLEDB:Engine Type=5;Provider="Microsoft.Jet.OLEDB.4.0";Jet OLEDB:System database=;Jet OLEDB:SFP=False;persist security info=False;Extended Properties=;Mode=Share Deny None;Jet OLEDB:Encrypt Database=False;Jet OLEDB:Create System Database=False;Jet OLEDB:Don't Copy Locale on Compact=False;Jet OLEDB:Compact Without Replica Repair=False;User ID=Admin;Jet OLEDB:Global Bulk Transactions=1" /> <add key="idx_DatabaseAdapter.AcceptChangesDuringFill" value="True" /> </appSettings> </configuration> The smillies should read OLDB: [edit]Robby removed smilies[/edit]dynamicconstring.bmp Edited November 29, 2003 by Robby Quote Trust the Universe
Moderators Robby Posted November 29, 2003 Moderators Posted November 29, 2003 Here's an example of a dynamic connection string... Dim strSQL As String = "SELECT * FROM SomeTable" Dim cn As New OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Password="""";User ID=Admin;Data Source=" & Application.StartupPath & "\myDatabase.mdb") Dim cmd As New OleDbCommand(strSQL, cn) Dim da As New OleDbDataAdapter(cmd) Dim ds As New DataSet() da.Fill(ds, "SomeTable") With DataGrid1 .DataSource = ds.Tables(0) .Visible = True End With Quote Visit...Bassic Software
feurich Posted November 30, 2003 Author Posted November 30, 2003 (edited) Does this means that when you want to write a ADO.NET application that connects with a access database independant of the location of the mdb file, you have to programmaticly connect to the database and get your information by programming the command adapter, database adpater? Cire Edited November 30, 2003 by feurich Quote Trust the Universe
Moderators Robby Posted November 30, 2003 Moderators Posted November 30, 2003 It's your choice. But doing it at runtime is much easier as well as scalable. Quote Visit...Bassic Software
feurich Posted December 1, 2003 Author Posted December 1, 2003 OK it works OK it works I put every thing in a Class DBServices and there the whole database connection is handled. The program seems to run much faster and smoother then before. Now the location of the exe program is the path where the application looks for the database. :p Very Happy Cire. Thanks you all. Quote Trust the Universe
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.