Hi Guys
I am a C-Sharp begginner. I am trying to store my Connection String in Web.config and then call it in my C-Sharp code. I have been doing this for a week now and i cnt get it right. Please help.
How to store a ConnectionString in Web.conf - C-Sharpstore and retrieve
Page 1 of 1
3 Replies - 806 Views - Last Post: 22 April 2010 - 07:12 AM
#1
How to store a ConnectionString in Web.conf - C-Sharp
Posted 22 April 2010 - 01:56 AM
Replies To: How to store a ConnectionString in Web.conf - C-Sharp
#2
Re: How to store a ConnectionString in Web.conf - C-Sharp
Posted 22 April 2010 - 04:33 AM
Make sure you have a connection to the database in Server Explorer in Visual Studio
Insert a sqldatasource into your page
Click the arrow that appears when you mouse over the sqldatasource (in design view) and select configure data source
Select your database from the drop down
Click Next
Name the connection string
Finish the sqldatasource however you want, just be sure to finish it by pressing Finish at the bottom
The connectionstring is now saved in web.config and that sqldatasource can be used or deleted as you see fit
Insert a sqldatasource into your page
Click the arrow that appears when you mouse over the sqldatasource (in design view) and select configure data source
Select your database from the drop down
Click Next
Name the connection string
Finish the sqldatasource however you want, just be sure to finish it by pressing Finish at the bottom
The connectionstring is now saved in web.config and that sqldatasource can be used or deleted as you see fit
#3
Re: How to store a ConnectionString in Web.conf - C-Sharp
Posted 22 April 2010 - 04:36 AM
Think we'll move this to ASP.NET.
#4
Re: How to store a ConnectionString in Web.conf - C-Sharp
Posted 22 April 2010 - 07:12 AM
Post the connection string from your web.config and include the code showing how you are trying to access the value. You should be using the ConfigurationManager.ConnectionStrings to get the value from your web.config.
Page 1 of 1
|
|

New Topic/Question
Reply




MultiQuote






|