Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6787601
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T17:23:08+00:00 2026-05-26T17:23:08+00:00

I am currently trying to establish a connection between an ASP.NET web site project

  • 0

I am currently trying to establish a connection between an ASP.NET web site project and a Database built by SQL Server 2008 R2.

The way I am required to do so is to use the connectionString from the Web.config page, but I have no idea what value to give it or how to establish a connection using said value. (Using C#)

Any help would be appreciated, as I found next to no information about the subject.

Here is the (default) value that is currently in the Web.config page:

<connectionStrings>
    <add name="ApplicationServices" connectionString="data source=.\SQLEXPRESS;Integrated Security=SSPI;AttachDBFilename=|DataDirectory|\aspnetdb.mdf;User Instance=true" providerName="System.Data.SqlClient"/>
</connectionStrings>
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-26T17:23:09+00:00Added an answer on May 26, 2026 at 5:23 pm

    Use Configuration Manager:

    using System.Data.SqlClient;
    using System.Configuration;
    
    string connectionString = ConfigurationManager.ConnectionStrings["ApplicationServices"].ConnectionString;
    
    using(SqlConnection SqlConnection = new SqlConnection(connectionString));
    

    //The rest is here to show you how this connection would be used. But the code above this comment is all you really asked for, which is how to connect.

    {
    
       SqlDataAdapter SqlDataAdapter = new SqlDataAdapter();
       SqlCommand SqlCommand = new SqlCommand();
    
       SqlConnection.Open();
       SqlCommand.CommandText = "select * from table";
       SqlCommand.Connection = SqlConnection;
       SqlDataReader dr = SqlCommand.ExecuteReader(CommandBehavior.CloseConnection);
    
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying to import CSV file to SQL server database, with no success.
I'm trying to establish a connection with a database in a Windows CE 5.0
I am currently trying out visual studio to access sql server databases instead of
I currently trying to decide which embedded database to pick up for new .NET
I'm trying to establish an interactive SSH connection to a remote server using PHP
My team is currently trying to automate the deployment of our .Net and PHP
I am trying to establish a TCP connection with a number of IPs in
I'm trying to establish a best practice for Virtual Machines for developers. Currently we
While trying to connect to a database that's set to read only, the connection
Here's a snippet of a web server that I am currently building... // ...

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.