dataconnectivity in asp.net with C# RRS feed

  • Question

  • how to connect to database in asp.net new website
    • Moved by nobugz Monday, October 5, 2009 8:13 AM forums.asp.net (From:Visual C# Express Edition)
    Monday, October 5, 2009 5:44 AM


All replies

  •  Hi Himmat,

     Thank you for your post!  I would suggest please post your question in the forum

     HomeASP.NET Forums » .NET Languages » C#

     located here: http://forums.asp.net/37.aspx

     Have a great day!!!!!

    Swapnil Tier 2 Application Support Server and Tools Online Operations Team
    • Proposed as answer by swapnilpBanned Monday, October 5, 2009 1:29 PM
    • Marked as answer by Just Karl Friday, October 17, 2014 9:16 PM
    Monday, October 5, 2009 1:29 PM
  • It is very is try this code

    You have to write this code in web.config file of your asp.net project and then call the connection from your web form here is the code for web.config

        <add name="ConnectionNameHere"
             connectionString="Data Source=(localhost);Initial Catalog=DataBaseName;User Id=UserName;Password=password;" 
             providerName="System.Data.SqlClient" />

    code for calling connection, write this code in code behind file (default.aspx.cs) 

     private string connectionString()
                return WebConfigurationManager.ConnectionStrings["ConnectionNameHere"].ConnectionString;
    Please, if this is a answer mark as answer   

    Thursday, October 2, 2014 2:54 AM