Selecting The Database to Use in ASP.NET code...

Posted on 2005-05-02
Last Modified: 2010-04-07
This should be an easy one.  I've learned how to use ASP.NET to modify the Northwind Database.  Now, I want to write a page to modify a DIFFERENT database, but I don't know how to identify it.

You see, in the ASP.NET code, Northwind is identified as "NWind".  Nowhere in the database's information or properties am I able to find this name.  I need to use the same-level of name for my new database, but I don't know what name that would be.  How do I find out?
Question by:brassmonkeyboy
    LVL 16

    Expert Comment

    Is this an Access database or SQL Server?
    You can use the Server Explorer (above the toolbox on the left)
    in Visual Studio to access databases that are local or on another server.

    Or you can access the new database in Code like this:
    This example uses SQL Server:

    ConnectionString ="server=localhost;Initial Catalog=MyData;User Id=sa;Password="

     Dim connection As New SqlConnection(ConnectionString )
          Dim command As New SqlCommand("GetCatInDept", connection)
          command.CommandType = CommandType.StoredProcedure
          command.Parameters.Add("@DepartmentID", SqlDbType.Int, 4)
          command.Parameters("@DepartmentID").Value = departmentId
             Return command.ExecuteReader(CommandBehavior.CloseConnection)
          Catch e As Exception
             Throw e
          End Try

    Author Comment

    Hrm..I don't think I was as clear as I should have been.  I have connected to it fine through the Server Explorer (It's sql btw).

    The code I've been using to access the Northwind database in code is like this:

    Dim strConnection As String = ConfigurationSettings.AppSettings("NWind")

    Now, I just want to use this to connect to my db instead of Northwind.  But I can't find a single occurance of the name "NWind" so I can figure out just how to identify my new database.  What does the "NWind" refer to precisely?
    LVL 16

    Expert Comment

    My only guess is that it could be a  DSN  . . .  
    Control Panel, Admin Tools, Data Sources (ODBC)
    See if it is listed in there.

    So you are saying you want to replace your database name with NWind?



    Author Comment

    Nothing's listed in the DSN list at all...

    Yeah, I want to do this:


    But I don't know what exactly to put in for "YourDatabaseName" because I don't know the source of the NWind name.
    LVL 16

    Accepted Solution

    open up your Web.config file .  .
    look for something like this:

    <add key="NWind" value="server=localhost;Initial Catalog=Northwind;User Id=sa;Password=" />

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    Free Trending Threat Insights Every Day

    Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

    Suggested Solutions

    Title # Comments Views Activity C# Stream to WorkBook 5 43
    Refresh page ASP.NET C# 3 39
    ASP.NET MVC Create/Edit ViewModel 7 51
    Javascript newbie 5 30
    I have developed many web applications with asp & and to add and use a dropdownlist was always a very simple task, but with the new, setting the value is a bit tricky and its not similar to the old traditional method. So in this a…
    In this Article, I will provide a few tips in problem and solution manner. Opening an ASPX page in Visual studio 2003 is very slow. To make it fast, please do follow below steps:   Open the Solution/Project. Right click the ASPX file to b…
    Migrating to Microsoft Office 365 is becoming increasingly popular for organizations both large and small. If you have made the leap to Microsoft’s cloud platform, you know that you will need to create a corporate email signature for your Office 365…
    how to add IIS SMTP to handle application/Scanner relays into office 365.

    758 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    11 Experts available now in Live!

    Get 1:1 Help Now