?
Solved

connection string dynamic server value

Posted on 2011-03-08
5
Medium Priority
?
233 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 2000 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

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Real-time is more about the business, not the technology. In day-to-day life, to make real-time decisions like buying or investing, business needs the latest information(e.g. Gold Rate/Stock Rate). Unlike traditional days, you need not wait for a fe…
This article shows how to deploy dynamic backgrounds to computers depending on the aspect ratio of display
If you’ve ever visited a web page and noticed a cool font that you really liked the look of, but couldn’t figure out which font it was so that you could use it for your own work, then this video is for you! In this Micro Tutorial, you'll learn yo…
Visualize your data even better in Access queries. Given a date and a value, this lesson shows how to compare that value with the previous value, calculate the difference, and display a circle if the value is the same, an up triangle if it increased…
Suggested Courses

771 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