Results 1 to 3 of 3

Thread: Connection String Issue

  1. #1

    Thread Starter
    Hyperactive Member
    Join Date
    Sep 2010
    Posts
    323

    Connection String Issue

    Hi there,

    I created a small accounting software for my clients using vb.net and SQL server 2014, and i used following connection string, please have a look:

    Code:
     
    
    Public SqlConStr As String = "Server=Server2; Database=DataFileXYZCo; User Id=sa; Password="test123#;"
    Conn.ConnectionString = SqlConStr
    Conn.Open()
    This connection string is working perfectly, the issue is when I make changes for my clients in source files, before copying application file, I have to change the "Server" name in Connection string, as you can see right now its Server2 but on client site its "PTSServer", all 12 customers have different server names. I have 12 clients right now for each client before copying Exe file I have to change the server name and then transfer Exe file.

    Is there any way I can create application file and copy to all my 12 customers without changing Server Name?
    Please note that I cannot use "local" or "localhost" in server name because application is running on network on each client.

    Thanks in advance.

    Ladak
    Last edited by accmaster; Jan 29th, 2018 at 06:16 AM.

  2. #2
    Wall Poster TysonLPrice's Avatar
    Join Date
    Sep 2002
    Location
    Columbus, Ohio
    Posts
    3,834

    Re: Connection String Issue

    We pass the connection string as a parameter to the executable to set the environment. Maybe you can do something like that. Or maybe use an ini file and look up the proper environment from there.
    Please remember next time...elections matter!

  3. #3
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    110,299

    Re: Connection String Issue

    Open the Settings page of the project properties and add a connection string there. You can then access that in code via My.Settings. The connection string you set will be stored in the config file and your users can edit that by hand after deployment, or you can edit it before deployment.

Posting Permissions

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



Click Here to Expand Forum to Full Width