Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Need SQL Server connection string to use variables.

Posted on 2013-01-31
2
Medium Priority
?
312 Views
Last Modified: 2013-01-31
Hello,

I need to pass a set of dynamic variables to a sqlserver connection string.

The variables come from a configuration table.

                sServerName = sBO_HL7_DBSchemas.ServerName
                sDatabase = sBO_HL7_DBSchemas.SchemaName
                sSchemaUN = sBO_HL7_DBSchemas.SchemaUN
                sSchemaPW = sBO_HL7_DBSchemas.SchemaUN
   
I would like to pass them into the connection string.

connetionString = "Data Source=ServerName;Initial Catalog=DatabaseName;User ID=UserName;Password=Password"

Thanks for the example.

Michael
0
Comment
Question by:MIREESE
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 33

Accepted Solution

by:
knightEknight earned 2000 total points
ID: 38841001
Are you working in VB?  Something like this...

  sServerName = sBO_HL7_DBSchemas.ServerName
  sDatabase = sBO_HL7_DBSchemas.SchemaName
  sSchemaUN = sBO_HL7_DBSchemas.SchemaUN
  sSchemaPW = sBO_HL7_DBSchemas.SchemaUN

  connetionString = "Data Source=" & sServerName & ";Initial Catalog=" & sDatabase & ";User ID=" & sSchemaUN  & ";Password=" & sSchemaPW
0
 

Author Closing Comment

by:MIREESE
ID: 38842659
Perfect, thank you:)
0

Featured Post

What is SQL Server and how does it work?

The purpose of this paper is to provide you background on SQL Server. It’s your self-study guide for learning fundamentals. It includes both the history of SQL and its technical basics. Concepts and definitions will form the solid foundation of your future DBA expertise.

Question has a verified solution.

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

Naughty Me. While I was changing the database name from DB1 to DB_PROD1 (yep it's not real database name ^v^), I changed the database name and notified my application fellows that I did it. They turn on the application, and everything is working. A …
If you have heard of RFC822 date formats, they can be quite a challenge in SQL Server. RFC822 is an Internet standard format for email message headers, including all dates within those headers. The RFC822 protocols are available in detail at:   ht…
This is my first video review of Microsoft Bookings, I will be doing a part two with a bit more information, but wanted to get this out to you folks.
Want to learn how to record your desktop screen without having to use an outside camera. Click on this video and learn how to use the cool google extension called "Screencastify"! Step 1: Open a new google tab Step 2: Go to the left hand upper corn…

721 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