Link to home
Start Free TrialLog in
Avatar of brassmonkeyboy
brassmonkeyboy

asked on

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?
Avatar of MikeMCSD
MikeMCSD
Flag of United States of America image

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
      Try
         connection.Open()
         Return command.ExecuteReader(CommandBehavior.CloseConnection)
      Catch e As Exception
         connection.Close()
         Throw e
      End Try
Avatar of brassmonkeyboy
brassmonkeyboy

ASKER

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?

ConfigurationSettings.AppSettings("YourDatabaseName")

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

Yeah, I want to do this:

ConfigurationSettings.AppSettings("YourDatabaseName")

But I don't know what exactly to put in for "YourDatabaseName" because I don't know the source of the NWind name.
ASKER CERTIFIED SOLUTION
Avatar of MikeMCSD
MikeMCSD
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial