We help IT Professionals succeed at work.
Get Started

How can I read an SQL connection string from a textbox?

jazjef asked
Last Modified: 2012-06-22
How can I read an SQL connection string from a textbox?

I have seen a couple of examples for this on EE but I can't get them to work for my situation.....

Here is my connection string function:

        Dim conPACBEW As New SqlConnection
        Dim sConnectionString As String _
            = "Data Source=COMPAQ12345AB;" _
            & "Initial Catalog=PACBEW;" _
            & "Integrated Security=SSPI"
        conPACBEW.ConnectionString = sConnectionString
        Return conPACBEW

What I want to do is read this connection string from a textbox that gets the connection string from a textfile.....  I don't want to have to recompile if I want to change the connection string parameters in the future.

I can read text files into a textbox called 'txtConnectionString.Text' on the interface to provide the information for the connection, I just can't get the connection string set up to read from txtConnectionString.Text

Any help is really appreciated... THANKS.

Watch Question
This problem has been solved!
Unlock 1 Answer and 17 Comments.
See Answer
Why Experts Exchange?

Experts Exchange always has the answer, or at the least points me in the correct direction! It is like having another employee that is extremely experienced.

Jim Murphy
Programmer at Smart IT Solutions

When asked, what has been your best career decision?

Deciding to stick with EE.

Mohamed Asif
Technical Department Head

Being involved with EE helped me to grow personally and professionally.

Carl Webster
CTP, Sr Infrastructure Consultant
Ask ANY Question

Connect with Certified Experts to gain insight and support on specific technology challenges including:

  • Troubleshooting
  • Research
  • Professional Opinions
Did You Know?

We've partnered with two important charities to provide clean water and computer science education to those who need it most. READ MORE