mkarthik415
asked on
connection string dynamic server value
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
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
For which DBMS?
ASKER
We are using Sql Server 2008.
Data Source in the connection refers to the server. So you want to point people to different database servers based on "userType"?
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
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
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