CodeCharge Studio
search Register Login  

Web Reports

Visually create Web Reports in PHP, ASP, .NET, Java, Perl and ColdFusion.
CodeCharge.com

YesSoftware Forums -> CodeCharge Studio -> .NET

 Dynamic Connection string

Print topic Send  topic

Author Message
Vasiliy

Posts: 378
Posted: 10/17/2006, 10:15 AM

I'm looking for a "Dynamic Connection string" solution for .Net

In my app I decide what DB to use depending on site VDir. So, the DB connection string can not be hardly coded in CCS project settings.

Year or two ago I had a problem with Dynamic Connection to the DB for Classic ASP.
Problem was solved with Piter's help.
The solution was to put in project seetings the connection like:
Provider=SQLOLEDB.1;Password=" & Session("ClientSQL_Password") & ";Persist Security Info=True;User ID=" & Session("ClientSQL_User") & ";Initial Catalog=" & Session("ClientSQL_DB") & ";Data Source=" & Session("ClientSQL_Server") & "

And then init session vars before connecting to the DB so that application uses dynamic DB connection.

In .Net it does not work because in "web.config" all " and & are replaced by " &.
Any ideas?

"Provider=SQLOLEDB.1;Password=" & Session("ClientSQL_Password") & ";Persist Security Info=True;User ID=" & Session("ClientSQL_User") & ";Initial Catalog=" & Session("ClientSQL_DB") & ";Data Source=" & Session("ClientSQL_Server") & "
_________________
Vasiliy
View profile  Send private message
Vasiliy

Posts: 378
Posted: 10/17/2006, 12:47 PM

Suggestions from CCS support with my followup:
---------------------------------
Case # 983923685
Summary "Dynamic Connection string" solution for .Net
Description is the same as above.

Posted 10/17/2006 1:17:18 PM
Last Update 10/17/2006 3:32:48 PM
---------------------------------
Responses
Posted 10/17/2006 2:53:30 PM
User Ruslan L.
Status Hold - Proposed Solution
Response Hello,
Maybe the following links would be useful for you:
http://forums.microsoft.com/MSDN/ShowPost.aspx?PostID=784717&SiteID=1
http://www.codeproject.com/asp/database.asp
http://www.codeproject.com/useritems/Dynamic_Connection_String.asp
---------------------------------
Posted 10/17/2006 3:32:48 PM
User vgoncharenko@armco.us
Status Hold - Proposed Solution
Response Ruslan,
thank you for Proposed Solutions.

Unfortunately none of them will work because:
1. solution http://forums.microsoft.com/MSDN/ShowPost.aspx?PostID=784717&SiteID=1
can not work because CodeCharge can not hanle multiple connections in web-config.
CodeCharge can read only one connection string name for associated connection.

2. solution http://www.codeproject.com/asp/database.asp
is proposed for Access files.

3. last solution is what I tried but it does not work because in "web.config" all " and & are replaced by characters. So, at run time I'm getting an error message becuase CodeCharge does not translate special characters back.

Any other ideas?
Maybe some patch for CCS3 that will make reversal transformation?
---------------------------------
_________________
Vasiliy
View profile  Send private message
Vasiliy

Posts: 378
Posted: 10/19/2006, 6:53 AM

Suggestions from CCS support with my followup:
---------------------------------
Posted 10/19/2006 3:58:21 AM
User Ruslan L.
Status Hold - Proposed Solution
Response
Hello,
You can try to modify the code in Settings.vb file, which is charged with reading the connection string.
Please follow the steps below :
1. Set the connection string in the following format:
Provider=SQLOLEDB.1;Password={0};Persist Security Info=True;User ID={1};Initial Catalog={2};Data Source={3}
2. After that, please locate the following property in the settings.vb file:
Public Shared ReadOnly Property <Connection name>Connection As ConnectionString

and change its connection string value from:
cs.Connection = System.Configuration.ConfigurationSettings.AppSettings("<Connection Name>String")

to

cs.Connection = String.Format(System.Configuration.ConfigurationSettings.AppSettings("<Connection Name>String"), Password, User, Datasource, server)

You can access a session in this file via System.Web.HttpContext.Current.Session
---------------------------------

Posted 10/19/2006 8:44:29 AM
User vgoncharenko@armco.us
Status Hold - Proposed Solution
Response

Ruslan,
thank you for proposed solution.

We thought the same way and unfortunately did this 2 days ago.
"Unfortunately" because with this way we lost "Settings.vb" automatic code re-generation. Before I was able to avoid code changes in auto-generated (gray) areas.

I was asking for dynamic connection solution 2 years ago for Classic ASP.
Later Yes issued CCS3 w/o dynamic connection (ans I was active beta tester).
Now I'm asking the same solution for .Net, and I'm not alone in this request (take a look at support forum).

I'm your customer for 2 years, developing complex web-applications (not web-sites), purchased 4 prop. licenses.
Maybe Yes can consider dynamic connection solution in the future?
_________________
Vasiliy
View profile  Send private message
Vasiliy

Posts: 378
Posted: 10/19/2006, 6:55 AM

Bottomline: so far there is no Dynamic Connection string solution for .Net in CCS3 unless you agree to change the auto-generated code in Settings.vb.
_________________
Vasiliy
View profile  Send private message

Add new topic Subscribe to topic   


These are Community Forums for users to exchange information.
If you would like to obtain technical product help please visit http://support.yessoftware.com.

Web Database

Join thousands of Web developers who build Web applications with minimal coding.
CodeCharge.com

Home   |    Search   |    Members   |    Register   |    Login


Powered by UltraApps Forum created with CodeCharge Studio
Copyright © 2003-2004 by UltraApps.com  and YesSoftware, Inc.