Solved

Need SQL Server connection string to use variables.

Posted on 2013-01-31
2
300 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
2 Comments
 
LVL 33

Accepted Solution

by:
knightEknight earned 500 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

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Generate Scripts of Schema/Data with "WHERE" clause 6 72
SQL query with cast 38 51
SQL 2008 R2 syntax 11 35
Addition to SQL for dynamic fields 6 47
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 …
In this article I will describe the Detach & Attach method as one possible migration process and I will add the extra tasks needed for an upgrade when and where is applied so it will cover all.

839 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