dcsimg
Results 1 to 3 of 3

Thread: Connection String Issue

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    Sep 2010
    Posts
    252

    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
    PowerPoster TysonLPrice's Avatar
    Join Date
    Sep 2002
    Location
    Columbus, Ohio
    Posts
    3,162

    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
    .NUT jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    100,386

    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.
    Why is my data not saved to my database? | MSDN Data Walkthroughs
    VBForums Database Development FAQ
    My CodeBank Submissions: VB | C#
    My Blog: Data Among Multiple Forms (3 parts)
    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