Solved

Need SQL Server connection string to use variables.

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

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

This is basically a blog post I wrote recently. I've found that SARGability is poorly understood, and since many people don't read blogs, I figured I'd post it here as an article. SARGable is an adjective in SQL that means that an item can be fou…
In this article I will describe the Backup & Restore 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.
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…
This video gives you a great overview about bandwidth monitoring with SNMP and WMI with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're looking for how to monitor bandwidth using netflow or packet s…

708 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

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now