Click here to Skip to main content
16,012,028 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
Dear All,
I want to deploy my asp.net web application into another PC. I am using SQL server database. I have taken the database backup and uploaded into host PC. But Host PC SQL server credentials are different( username, password..etc).
I am using connection string in my .cs files. Do I need to change all the connection string in .cs file or is there any other way?

Thanks in advance.
Posted
Comments
Sergey Alexandrovich Kryukov 11-Mar-13 13:14pm    
I would strongly recommend you make SQL server a prerequisite for your product installation. The user would be supposed to do the setup according the user's license.
—SA
sjelen 11-Mar-13 13:43pm    
It's a bad idea to have connection strings hard coded in .cs files. Put your connection strings in a config file (connection strings section) and make your app read them on start. That way you can change them easily without editing and re-compiling the code.

Instead of generating the connection string in cs, it would be a best practice to use connection string in web.config.

So, when you publish to different server, just change the web.config.

http://www.connectionstrings.com/Articles/Show/store-connection-string-in-web-config[^]

SqlConnection con = new SqlConnection(System.Configuration.ConfigurationManager.ConnectionStrings["ConnectionStringNameFromWebConfig"].ConnectionString);

Hope this helps.

cheers
 
Share this answer
 
Comments
2012programmer 11-Mar-13 17:29pm    
Thank you Mr. Sandip, It is working very fine. The hyperlink you have provided is very useful for me.
I have 2 more queries, kindly help me in this regard. 1. How to publish this asp.net application. (Is there any step by step article is available ?). 2. After publishing this application If I want to change my connection string in web.config file, How Can I do this (There is no visual studio in Host system).
Sandip.Nascar 11-Mar-13 17:39pm    
check the link
http://www.codeproject.com/Questions/128591/publish-website

before you publish, change the connectionstring in web.config.
If you are using local folder to publish, you can change in published folder and then upload.
Hello,
This usually happens when you try to access a SQL SERVER database located on a PC within a LAN that does not have a domain controller, you should change your connection string windows integrated security to SQL Server connection safely , with this you can access from any application to SQL service.

Another point to consider is: if the database server host and the web server (IIS) are the same just serious enough to give access permissions to the database user ASPNET or IUSR HOST.

I hope I have been helpful, tell me if you have questions
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900