Skip to content

How to control Database connection in C# Application

paingsoe thu

Asked Oct 8, 2013, 7:30 PM EDT1 answer
Share
LinkedInX
Dear senior programmers....

                Please help me.I have a c# application.This application include localdatabase .sdf.
This application compiled to setup file.exe.This setup.exe install to other computer then error message show is database path error.Tell me how to write this database path no change  and I don't wish  install sqlserver to  this application installation other computer.
example ..............protable style application.(Like Directory application)Other computer no database server and this application is not change and successfully installation.Please tell me thank.

1 Answer

Know the answer? Post it. Somebody with the same question will find it here.

  • Dharmendra Singh
    0
    check your connection string like this..


    add app.config file


    <?xml version="1.0" encoding="utf-8"?>
    <configuration>
      <configSections></configSections>
      <connectionStrings>
        <add name="JSInventory.Properties.Settings.InventoryConnectionString1" connectionString="Data Source=|DataDirectory|\Inventory.sdf" providerName="Microsoft.SqlServerCe.Client.3.5" />
      </connectionStrings>
    </configuration>


    and use this connection string like

    string connection=JSInventory.Properties.Settings.InventoryConnectionString1;
    0