none
datasource connection string problem RRS feed

  • Question

  • When adding a Data Source in VS2005 VB.NET, the wizard helps build and test a connection string which is stored with the apps settings. The connection string contains ComputerName\ServerInstance which is fine if it were to stay on the development machine. When it is installed on the client's computer, the ComputerName should be changed to the client's computer name. I tried doing it with the following:

     

    Dim s As String = My.Settings.CmdCenterConnectionString.Replace("DevelopmentComputerName", My.Computer.Name)

     

    Unfortunately, it doesn't change anything. The original DevelopmentComputerName is still in the ClientsApp.exe.config file and, of course, generates an error. How can the connection string stored in Settings be changed in a manner which does not require user action?

    Wednesday, April 2, 2008 4:27 PM

Answers

  • What good is it if it won't work on anybody else's computer? The wizard automatically saves the development computer's name.

     

    The answer to my question is actually simple. When the connection is made using the wizard, instead of using the ComputerName\ServerInstance (default), type "." (no quotes) in place of the ComputerName. For example, ".\MyServerInstance" (no quotes).

     

    Solved the problem toot sweet.

    Friday, April 4, 2008 4:06 PM

All replies

  • See if the following helps:

    http://msdn2.microsoft.com/en-us/library/a65txexh(VS.80).aspx



    Thursday, April 3, 2008 1:42 PM
  • As I understand it, that page basically says that applications settings cannot be changed at runtime. Under those circumstances it seems that saving connection strings in applications settings is a useless, error generating procedure. Why does VS do that? And, is there a better way? 

    Thursday, April 3, 2008 2:57 PM
  • It's not useless. The difference is that you're using the wizards to generate your datasets, which saves this information for you automatically, as opposed to creating your data objects in code, where it's much easier to dynamically implement your connections from an application setting.

    Friday, April 4, 2008 1:23 PM
  • What good is it if it won't work on anybody else's computer? The wizard automatically saves the development computer's name.

     

    The answer to my question is actually simple. When the connection is made using the wizard, instead of using the ComputerName\ServerInstance (default), type "." (no quotes) in place of the ComputerName. For example, ".\MyServerInstance" (no quotes).

     

    Solved the problem toot sweet.

    Friday, April 4, 2008 4:06 PM