Solved

Need SQL Server connection string to use variables.

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

On Demand Webinar - Networking for the Cloud Era

This webinar discusses:
-Common barriers companies experience when moving to the cloud
-How SD-WAN changes the way we look at networks
-Best practices customers should employ moving forward with cloud migration
-What happens behind the scenes of SteelConnect’s one-click button

Question has a verified solution.

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

I have written a PowerShell script to "walk" the security structure of each SQL instance to find:         Each Login (Windows or SQL)             * Its Server Roles             * Every database to which the login is mapped             * The associated "Database User" for this …
Occasionally there is a need to clean table columns, especially if you have inherited legacy data. There are obviously many ways to accomplish that, including elaborate UPDATE queries with anywhere from one to numerous REPLACE functions (even within…
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…
In a recent question (https://www.experts-exchange.com/questions/29004105/Run-AutoHotkey-script-directly-from-Notepad.html) here at Experts Exchange, a member asked how to run an AutoHotkey script (.AHK) directly from Notepad++ (aka NPP). This video…

735 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