3 Replies - 1063 Views - Last Post: 22 April 2010 - 07:12 AM Rate Topic: -----

#1 lukhanyo  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 1
  • Joined: 22-April 10

How to store a ConnectionString in Web.conf - C-Sharp

Posted 22 April 2010 - 01:56 AM

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.
Is This A Good Question/Topic? 0
  • +

Replies To: How to store a ConnectionString in Web.conf - C-Sharp

#2 Nakor  Icon User is offline

  • Professional Lurker
  • member icon

Reputation: 444
  • View blog
  • Posts: 1,492
  • Joined: 28-April 09

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
Was This Post Helpful? 0
  • +
  • -

#3 JackOfAllTrades  Icon User is offline

  • Saucy!
  • member icon

Reputation: 6063
  • View blog
  • Posts: 23,517
  • Joined: 23-August 08

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.
Was This Post Helpful? 0
  • +
  • -

#4 Jayman  Icon User is offline

  • Student of Life
  • member icon

Reputation: 418
  • View blog
  • Posts: 9,532
  • Joined: 26-December 05

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.
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1