Jump to content
Xtreme .Net Talk

Recommended Posts

Posted

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

Trust the Universe
  • Administrators
Posted

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.

Posting Guidelines FAQ Post Formatting

 

Intellectuals solve problems; geniuses prevent them.

-- Albert Einstein

Posted

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

:-\

Trust the Universe
Posted
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.
Dream as if you'll live forever, live as if you'll die today
Posted

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

Trust the Universe
Posted

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

Trust the Universe
Posted (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 by Robby
Trust the Universe
  • Moderators
Posted

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

Visit...Bassic Software
Posted (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 by feurich
Trust the Universe
Posted

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.

Trust the Universe

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...