[Last Call] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

Text Replacements - Connection String

Posted on 2007-07-26
3
Medium Priority
?
235 Views
Last Modified: 2010-05-18
I have a login screen which gives the user the option of changing the data source

"Data Source=(local);Initial Catalog=AquariusLive;User ID=Aquarius;Password=aquarius"

So if they type in ADAM it will pleace (local) with ADAM is there any easy way of doing this without breaking the string up
0
Comment
Question by:rocky050371
  • 3
3 Comments
 
LVL 18

Expert Comment

by:DarrenD
ID: 19573170
Hi,
How about this.

Dim MyString As String = "Data Source=(local);Initial Catalog=AquariusLive;User ID=Aquarius;Password=aquarius".Replace("(local)", TextBox1.Text)
        MessageBox.Show(MyString)
Darren
0
 
LVL 18

Expert Comment

by:DarrenD
ID: 19573190
You could put in some other match string other than (local) so that local could be used such as

Dim MyString As String = "Data Source=(~MyDatabase~);Initial Catalog=AquariusLive;User ID=Aquarius;Password=aquarius".Replace("(~MyDatabase~)", TextBox1.Text)
        MessageBox.Show(MyString)

This would allow (local) to be used as a datasource.

Darren
0
 
LVL 18

Accepted Solution

by:
DarrenD earned 2000 total points
ID: 19573198
You could also do a further replace if you wanted to replace a few values

        Dim MyString As String = "Data Source=(local);Initial Catalog=AquariusLive;User ID=Aquarius;Password=aquarius".Replace("(local)", TextBox1.Text).Replace("AquariusLive", TextBox2.Text)
        MessageBox.Show(MyString)

Hope this helps,

Darren
0

Featured Post

Efficient way to get backups off site to Azure

This user guide provides instructions on how to deploy and configure both a StoneFly Scale Out NAS Enterprise Cloud Drive virtual machine and Veeam Cloud Connect in the Microsoft Azure Cloud.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

For those of you who don't follow the news, or just happen to live under rocks, Microsoft Research released a beta SDK (http://www.microsoft.com/en-us/download/details.aspx?id=27876) for the Xbox 360 Kinect. If you don't know what a Kinect is (http:…
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
In a question here at Experts Exchange (https://www.experts-exchange.com/questions/29062564/Adobe-acrobat-reader-DC.html), a member asked how to create a signature in Adobe Acrobat Reader DC (the free Reader product, not the paid, full Acrobat produ…
Look below the covers at a subform control , and the form that is inside it. Explore properties and see how easy it is to aggregate, get statistics, and synchronize results for your data. A Microsoft Access subform is used to show relevant calcul…
Suggested Courses

829 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question