Solved

Need SQL Server connection string to use variables.

Posted on 2013-01-31
2
299 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

The Eight Noble Truths of Backup and Recovery

How can IT departments tackle the challenges of a Big Data world? This white paper provides a roadmap to success and helps companies ensure that all their data is safe and secure, no matter if it resides on-premise with physical or virtual machines or in the cloud.

Question has a verified solution.

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

Suggested Solutions

     When we have to pass multiple rows of data to SQL Server, the developers either have to send one row at a time or come up with other workarounds to meet requirements like using XML to pass data, which is complex and tedious to use. There is a …
Long way back, we had to take help from third party tools in order to encrypt and decrypt data.  Gradually Microsoft understood the need for this feature and started to implement it by building functionality into SQL Server. Finally, with SQL 2008, …
This video shows how to quickly and easily add an email signature for all users on Exchange 2016. The resulting signature is applied on a server level by Exchange Online. The email signature template has been downloaded from: www.mail-signatures…
Although Jacob Bernoulli (1654-1705) has been credited as the creator of "Binomial Distribution Table", Gottfried Leibniz (1646-1716) did his dissertation on the subject in 1666; Leibniz you may recall is the co-inventor of "Calculus" and beat Isaac…

803 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