Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 213
  • Last Modified:

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

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?
  • 3
  • 2
1 Solution
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
brassmonkeyboyAuthor Commented:
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?
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?


brassmonkeyboyAuthor Commented:
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.
open up your Web.config file .  .
look for something like this:

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

Featured Post

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

  • 3
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now