Solved

connection string dynamic server value

Posted on 2011-03-08
5
231 Views
Last Modified: 2012-06-21
Hi

Below is the connection string to my database.
Depending on the user provided value(suppose it as "userType"), the "data source" value "SERVERNAME" is changed ie depending on userType, the user is connected to database.

connectionString="Initial Catalog=IC1;Application Name=AN1;data source={SERVERNAME};User ID=xxx;password=xxx;"

Do any one has sample/ suggestion or links similar to this one. I am confused how "SERVERNAME" and "userType" are related to each other.

Thank You
0
Comment
Question by:mkarthik415
[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
5 Comments
 
LVL 75

Expert Comment

by:käµfm³d 👽
ID: 35075999
For which DBMS?
0
 

Author Comment

by:mkarthik415
ID: 35079857
We are using Sql Server 2008.
0
 
LVL 52

Expert Comment

by:Carl Tawn
ID: 35080371
Data Source in the connection refers to the server. So you want to point people to different database servers based on "userType"?
0
 
LVL 8

Accepted Solution

by:
Anurag Agarwal earned 500 total points
ID: 35081385
mkarthik415 no need to get confuse get the basic idea

"SERVERNAME"  : is the instance name of the sql server for which it is installed which Generally is installed by default with the IP address of the system or along with a instance name say for eg
u have lan ip as 192.10.5.20 , and sql server 2008 is installed with default instance name then your servername for sql server will be 192.10.5.20 (or . which means local server) if u have instance name along with say mkarthik415_SQLServer then "SERVERNAME will be 192.10.5.20\mkarthik415_SQLServer (or .\mkarthik415_SQLServer as local )

and "userType" is the user created for the particular databse like each database has default userid as sa you can also create userid for your db.

The  "SERVERNAME" and "userType" are related to each other in the manner that in connection string first u mention that which DB Server u are connecting , Second thing u need to mention Catalog is which database u r connecting and thirdly through which user u r connecting to that database.

User are  created as stating how much accessing, deleting or using rights are given to user for a database as sa user is administrator and u may not give all rights to all db users
0
 
LVL 8

Expert Comment

by:Anurag Agarwal
ID: 35081419
Function GetConnectionString() As String
        Dim Datasource As String = Txt_SqlSrvrName.Text
        Dim Catalog As String = txtCatalog.Text
        Dim userid As String = Txt_userID.Text
        Dim Pwd As String = txt_Pwd.Text

        Dim SMS_DistrictConn As String = "Data Source=" & Datasource & ";Initial Catalog=" & Catalog & ";Persist Security Info=True;User ID=sa;Password=" & Pwd & ";"

        Return SMS_DistrictConn
    End Function


do something like this and save the connection string in viewstate
0

Featured Post

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

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

Introduction This article shows how to use the open source plupload control to upload multiple images. The images are resized on the client side before uploading and the upload is done in chunks. Background I had to provide a way for user…
This article is for Object-Oriented Programming (OOP) beginners. An Interface contains declarations of events, indexers, methods and/or properties. Any class which implements the Interface should provide the concrete implementation for each Inter…
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …
Are you ready to implement Active Directory best practices without reading 300+ pages? You're in luck. In this webinar hosted by Skyport Systems, you gain insight into Microsoft's latest comprehensive guide, with tips on the best and easiest way…

738 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