Issue with old database filepath reference on deployment.-VBForums
Results 1 to 5 of 5

Thread: Issue with old database filepath reference on deployment.

  1. #1

    Thread Starter
    New Member
    Join Date
    Apr 2013
    Posts
    3

    Issue with old database filepath reference on deployment.

    Hi all,

    I am developing a VB.NET fault management system (single mdb database) and am having a real hard time with the installation on other machines.

    Basically I have developed the application on my machine, all works fine and the database connects perfectly.

    When I use the package and deployment wizard its all falling apart.

    Currently the connection string is set for the DB on my machine i.e:

    "Provider=Microsoft.Jet.OLEDB.4.0; Data Source = C:\Users\Dave\Documents\duraGadget.mdb;"

    The connection pah on the target installation machine (which contains a copy of the database) is:

    "Provider=Microsoft.Jet.OLEDB.4.0; Data Source = C:\Users\Public\Documents\duraGadget.mdb;"

    I simply scan the project for the old connection name and 'apparently' replace all instances of the old connection path with the new.

    I then use package and deployment and copy all of the file from the project.

    Once I install the app onto the new machine I am constantly getting an error that the old connection path cannot be found. This is really frustrating as I thought I had replaced all instances of it. This is the error message:

    Name:  failDB.jpg
Views: 75
Size:  46.7 KB

    From what I can work out I'm obviously including an old reference in the files of the package and deployment. Is there anyway I can fully scan and replace all the connection paths? And exactly how many files do I need to put in the package and deployment wizard.

    Thanks in advance for any help!

  2. #2
    .NUT jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    88,170

    Re: Issue with old database filepath reference on deployment.

    There's only one place that your connection string should appear: in the config file. Every time you need to use it, it gets read from there. If it needs to be edited then it's modified in the config file. It's a loose XML file so the connection string can even be edited by hand after deployment if required. You should add the connection string on the Settings page of the project properties, which will automatically add it to the config file. You can then access it in code via My.Settings.

    2007-2014

    Why is my data not saved to my database? | MSDN Data Walkthroughs
    MSDN "How Do I?" Videos: VB | C#
    VBForums Database Development FAQ
    My CodeBank Submissions: VB | C#
    My Blog: Data Among Multiple Forms (3 parts) | WP8 Turnstile Feather Transition with Pivot Control
    Beginner Tutorials: VB | C# | SQL

  3. #3

    Thread Starter
    New Member
    Join Date
    Apr 2013
    Posts
    3

    Re: Issue with old database filepath reference on deployment.

    Thanks for your reply. I have changed my connection string in the app.config folder as shown:

    Code:
    <?xml version="1.0" encoding="utf-8" ?>
    <configuration>
        <configSections>
        </configSections>
        <connectionStrings>
            <add name="DuraGadget.My.MySettings.duraGadgetConnectionString"
                connectionString="Provider=Microsoft.ACE.OLEDB.12.0;Data Source=C:\Users\Public\Documents\duraGadget.accdb"
                providerName="System.Data.OleDb" />
            <add name="DuraGadget.My.MySettings.duraGadgetConnectionString1"
                connectionString="Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\Users\Public\Documents\duraGadget.mdb"
                providerName="System.Data.OleDb" />
        </connectionStrings>
        <startup>
            <supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.0,Profile=Client" />
        </startup>
    </configuration>
    Settings file:

    Code:
    <?xml version='1.0' encoding='utf-8'?>
    <SettingsFile xmlns="http://schemas.microsoft.com/VisualStudio/2004/01/settings" CurrentProfile="(Default)" GeneratedClassNamespace="My" GeneratedClassName="MySettings" UseMySettingsClassName="true">
      <Profiles />
      <Settings>
        <Setting Name="duraGadgetConnectionString" Type="(Connection string)" Scope="Application">
          <DesignTimeValue Profile="(Default)">&lt;?xml version="1.0" encoding="utf-16"?&gt;
    &lt;SerializableConnectionString xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema"&gt;
      &lt;ConnectionString&gt;Provider=Microsoft.ACE.OLEDB.12.0;Data Source=C:\Users\Public\Documents\duraGadget.accdb&lt;/ConnectionString&gt;
      &lt;ProviderName&gt;System.Data.OleDb&lt;/ProviderName&gt;
    &lt;/SerializableConnectionString&gt;</DesignTimeValue>
          <Value Profile="(Default)">Provider=Microsoft.ACE.OLEDB.12.0;Data Source=C:\Users\Public\Documents\duraGadget.accdb</Value>
        </Setting>
        <Setting Name="duraGadgetConnectionString1" Type="(Connection string)" Scope="Application">
          <DesignTimeValue Profile="(Default)">&lt;?xml version="1.0" encoding="utf-16"?&gt;
    &lt;SerializableConnectionString xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema"&gt;
      &lt;ConnectionString&gt;Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\Users\Public\Documents\duraGadget.mdb&lt;/ConnectionString&gt;
      &lt;ProviderName&gt;System.Data.OleDb&lt;/ProviderName&gt;
    &lt;/SerializableConnectionString&gt;</DesignTimeValue>
          <Value Profile="(Default)">Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\Users\Public\Documents\duraGadget.mdb</Value>
        </Setting>
      </Settings>
    </SettingsFile>
    Now something you have said there about only declaring the connection once. I have 3 forms and have declared the connection at the top as shown:

    Name:  connstring.jpg
Views: 51
Size:  36.4 KB

    I have declared the string this way on each form.

    I still don't get what I'm doing wrong as the old connection string seems to persist!.
    Last edited by Flyjunkie; Apr 8th, 2013 at 09:11 AM.

  4. #4

    Thread Starter
    New Member
    Join Date
    Apr 2013
    Posts
    3

    Re: Issue with old database filepath reference on deployment.

    Also to add these are the details given within the error window:

    [CODE]See the end of this message for details on invoking
    just-in-time (JIT) debugging instead of this dialog box.

    ************** Exception Text **************
    System.Data.OleDb.OleDbException (0x80004005): 'C:\Users\Dave\Documents\duraGadget_be.mdb' is not a valid path. Make sure that the path name is spelled correctly and that you are connected to the server on which the file resides.
    at System.Data.OleDb.OleDbCommand.ExecuteCommandTextErrorHandling(OleDbHResult hr)
    at System.Data.OleDb.OleDbCommand.ExecuteCommandTextForSingleResult(tagDBPARAMS dbParams, Object& executeResult)
    at System.Data.OleDb.OleDbCommand.ExecuteCommandText(Object& executeResult)
    at System.Data.OleDb.OleDbCommand.ExecuteCommand(CommandBehavior behavior, Object& executeResult)
    at System.Data.OleDb.OleDbCommand.ExecuteReaderInternal(CommandBehavior behavior, String method)
    at System.Data.OleDb.OleDbCommand.ExecuteReader(CommandBehavior behavior)
    at System.Data.OleDb.OleDbCommand.System.Data.IDbCommand.ExecuteReader(CommandBehavior behavior)
    at System.Data.Common.DbDataAdapter.FillInternal(DataSet dataset, DataTable[] datatables, Int32 startRecord, Int32 maxRecords, String srcTable, IDbCommand command, CommandBehavior behavior)
    at System.Data.Common.DbDataAdapter.Fill(DataSet dataSet, Int32 startRecord, Int32 maxRecords, String srcTable, IDbCommand command, CommandBehavior behavior)
    at System.Data.Common.DbDataAdapter.Fill(DataSet dataSet, String srcTable)
    at DuraGadget.Form1.Form1_Load(Object sender, EventArgs e) in C:\Users\Dave\Documents\Visual Studio 2010\Projects\DSN Install\Install\DuraGadget\Form1.vb:line 20
    at System.EventHandler.Invoke(Object sender, EventArgs e)
    at System.Windows.Forms.Form.OnLoad(EventArgs e)
    at System.Windows.Forms.Form.OnCreateControl()
    at System.Windows.Forms.Control.CreateControl(Boolean fIgnoreVisible)
    at System.Windows.Forms.Control.CreateControl()
    at System.Windows.Forms.Control.WmShowWindow(Message& m)
    at System.Windows.Forms.Control.WndProc(Message& m)
    at System.Windows.Forms.ScrollableControl.WndProc(Message& m)
    at System.Windows.Forms.Form.WmShowWindow(Message& m)
    at System.Windows.Forms.Form.WndProc(Message& m)
    at System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m)
    at System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m)
    at System.Windows.Forms.NativeWindow.Callback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)


    ************** Loaded Assemblies **************
    mscorlib
    Assembly Version: 4.0.0.0
    Win32 Version: 4.0.30319.296 (RTMGDR.030319-2900)
    CodeBase: file:///C:/Windows/Microsoft.NET/Framework/v4.0.30319/mscorlib.dll
    ----------------------------------------
    DuraGadget
    Assembly Version: 1.0.0.0
    Win32 Version: 1.0.0.0
    CodeBase: file:///C:/Program%20Files%20(x86)/Default%20Company%20Name/DSN%20Installer/DuraGadget.exe
    ----------------------------------------
    Microsoft.VisualBasic
    Assembly Version: 10.0.0.0
    Win32 Version: 10.0.30319.1 built by: RTMRel
    CodeBase: file:///C:/Windows/Microsoft.Net/assembly/GAC_MSIL/Microsoft.VisualBasic/v4.0_10.0.0.0__b03f5f7f11d50a3a/Microsoft.VisualBasic.dll
    ----------------------------------------
    System
    Assembly Version: 4.0.0.0
    Win32 Version: 4.0.30319.1001 built by: RTMGDR
    CodeBase: file:///C:/Windows/Microsoft.Net/assembly/GAC_MSIL/System/v4.0_4.0.0.0__b77a5c561934e089/System.dll
    ----------------------------------------
    System.Core
    Assembly Version: 4.0.0.0
    Win32 Version: 4.0.30319.233 built by: RTMGDR
    CodeBase: file:///C:/Windows/Microsoft.Net/assembly/GAC_MSIL/System.Core/v4.0_4.0.0.0__b77a5c561934e089/System.Core.dll
    ----------------------------------------
    System.Windows.Forms
    Assembly Version: 4.0.0.0
    Win32 Version: 4.0.30319.1002 built by: RTMGDR
    CodeBase: file:///C:/Windows/Microsoft.Net/assembly/GAC_MSIL/System.Windows.Forms/v4.0_4.0.0.0__b77a5c561934e089/System.Windows.Forms.dll
    ----------------------------------------
    System.Drawing
    Assembly Version: 4.0.0.0
    Win32 Version: 4.0.30319.1001 built by: RTMGDR
    CodeBase: file:///C:/Windows/Microsoft.Net/assembly/GAC_MSIL/System.Drawing/v4.0_4.0.0.0__b03f5f7f11d50a3a/System.Drawing.dll
    ----------------------------------------
    System.Runtime.Remoting
    Assembly Version: 4.0.0.0
    Win32 Version: 4.0.30319.1 (RTMRel.030319-0100)
    CodeBase: file:///C:/Windows/Microsoft.Net/assembly/GAC_MSIL/System.Runtime.Remoting/v4.0_4.0.0.0__b77a5c561934e089/System.Runtime.Remoting.dll
    ----------------------------------------
    System.Data
    Assembly Version: 4.0.0.0
    Win32 Version: 4.0.30319.237 (RTMGDR.030319-2300)
    CodeBase: file:///C:/Windows/Microsoft.Net/assembly/GAC_32/System.Data/v4.0_4.0.0.0__b77a5c561934e089/System.Data.dll
    ----------------------------------------
    System.Xml
    Assembly Version: 4.0.0.0
    Win32 Version: 4.0.30319.233 built by: RTMGDR
    CodeBase: file:///C:/Windows/Microsoft.Net/assembly/GAC_MSIL/System.Xml/v4.0_4.0.0.0__b77a5c561934e089/System.Xml.dll
    ----------------------------------------
    System.Data.DataSetExtensions
    Assembly Version: 4.0.0.0
    Win32 Version: 4.0.30319.1 built by: RTMRel
    CodeBase: file:///C:/Windows/Microsoft.Net/assembly/GAC_MSIL/System.Data.DataSetExtensions/v4.0_4.0.0.0__b77a5c561934e089/System.Data.DataSetExtensions.dll
    ----------------------------------------
    System.Numerics
    Assembly Version: 4.0.0.0
    Win32 Version: 4.0.30319.1 built by: RTMRel
    CodeBase: file:///C:/Windows/Microsoft.Net/assembly/GAC_MSIL/System.Numerics/v4.0_4.0.0.0__b77a5c561934e089/System.Numerics.dll
    ----------------------------------------
    System.Transactions
    Assembly Version: 4.0.0.0
    Win32 Version: 4.0.30319.1 (RTMRel.030319-0100)
    CodeBase: file:///C:/Windows/Microsoft.Net/assembly/GAC_32/System.Transactions/v4.0_4.0.0.0__b77a5c561934e089/System.Transactions.dll
    ----------------------------------------
    System.EnterpriseServices
    Assembly Version: 4.0.0.0
    Win32 Version: 4.0.30319.1 (RTMRel.030319-0100)
    CodeBase: file:///C:/Windows/Microsoft.Net/assembly/GAC_32/System.EnterpriseServices/v4.0_4.0.0.0__b03f5f7f11d50a3a/System.EnterpriseServices.dll
    ----------------------------------------
    System.Configuration
    Assembly Version: 4.0.0.0
    Win32 Version: 4.0.30319.1 (RTMRel.030319-0100)
    CodeBase: file:///C:/Windows/Microsoft.Net/assembly/GAC_MSIL/System.Configuration/v4.0_4.0.0.0__b03f5f7f11d50a3a/System.Configuration.dll
    ----------------------------------------

    ************** JIT Debugging **************
    To enable just-in-time (JIT) debugging, the .config file for this
    application or computer (machine.config) must have the
    jitDebugging value set in the system.windows.forms section.
    The application must also be compiled with debugging
    enabled.

    For example:

    <configuration>
    <system.windows.forms jitDebugging="true" />
    </configuration>

    When JIT debugging is enabled, any unhandled exception
    will be sent to the JIT debugger registered on the computer
    rather than be handled by this dialog box.

    [/ CODE]

  5. #5
    .NUT jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    88,170

    Re: Issue with old database filepath reference on deployment.

    You shouldn't have the connection string in any forms at all. If you do then there's no point having it in the config file. As I said in my previous post, when you want to use the connection string in code you get it from the config file via My.Settings. In your case, you'd use My.Settings.duraGadgetConnectionString or My.Settings.duraGadgetConnectionString1.

    2007-2014

    Why is my data not saved to my database? | MSDN Data Walkthroughs
    MSDN "How Do I?" Videos: VB | C#
    VBForums Database Development FAQ
    My CodeBank Submissions: VB | C#
    My Blog: Data Among Multiple Forms (3 parts) | WP8 Turnstile Feather Transition with Pivot Control
    Beginner Tutorials: VB | C# | SQL

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Featured


Click Here to Expand Forum to Full Width

Survey posted by VBForums.