I created a simple ASP.NET webpage and when I run it I get a error.
The error is as follows: System.Data.SqlClient.SqlExeption: Cannot open database requested in login 'Students'. Login fails

The line of my code that is higlighted is:
objDataAdapter.Fill(objDataSet, "Student")

I created the database in Visual Studio.nets Server Explorer, The dataBase is called students and the table is student.

I modeled this program from a program I made that connects to the pubs dattabase.

The program that I made that connects to the pubs database works but this one doesn't.

The student database is in the same folder as the pubs database

Below is my code for the Students webform that isn't working, and below that is the code for the datagrid sorting webform (connects to pubs database) that works.

I appreciate any help I can get as I am a newbee,
Many thanks,
Glen Conaway

Imports System.Data
Imports System.Data.SqlClient
Public Class WebForm1
Inherits System.Web.UI.Page
Protected WithEvents grdStudents As System.Web.UI.WebControls.DataGrid

' Declare a Connection object that is Global in scope...
Dim objConnection As SqlConnection
#Region " Web Form Designer Generated Code "

'This call is required by the Web Form Designer.
<System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()

End Sub

Private Sub Page_Init(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Init
'CODEGEN: This method call is required by the Web Form Designer
'Do not modify it using the code editor.
InitializeComponent()
End Sub

#End Region

Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
'Put user code to initialize the page here

' Initialize the Connection objext...
objConnection = New SqlConnection("server=New\NetSdk;database=Students;Integrated Security=sspi")

' Only bind the data the first time the page is built...
' Subsequent post back will be to sort the data in the grid...
If Not (IsPostBack) Then
BindGrid("Last Name")
End If
End Sub

Sub BindGrid(ByVal strSortField As String)
' Declare objects
Dim objDataSet As DataSet
Dim objDataAdapter As SqlDataAdapter

' Set the SQL string..
objDataAdapter = New SqlDataAdapter("SELECT student_id AS 'Student ID', f_name AS 'First Name', l_name AS 'Last Name', city AS 'City', state AS 'State' From Student " & _
"ORDER BY l_name, f_name", objConnection)


' Initialize the DataSet object, and fill it...
objDataSet = New DataSet()
objDataAdapter.Fill(objDataSet, "Student")

' Declare a DataView object, populate it,
' and sort the data in it...
Dim objDataView As DataView = _
objDataSet.Tables("Student").DefaultView
objDataView.Sort = strSortField

' Bind the DataView object ot the DatGrid control...
grdStudents.DataSource = objDataView
grdStudents.DataBind()

' Clean up...
End Sub

Private Sub grdStudents_SortCommand(ByVal source As Object, ByVal e As System.Web.UI.WebControls.DataGridSortCommandEventArgs) Handles grdStudents.SortCommand
' Bind the DataGrid using the sort colum requested
BindGrid(e.SortExpression)
End Sub
End Class





Here is the code that works

Imports System.Data
Imports System.Data.SqlClient

Public Class WebForm1
Inherits System.Web.UI.Page
Protected WithEvents grdAuthors As System.Web.UI.WebControls.DataGrid

' Declare a connection object that is global in scope...
Dim objConnection As SqlConnection

#Region " Web Form Designer Generated Code "

'This call is required by the Web Form Designer.
<System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()

End Sub

Private Sub Page_Init(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Init
'CODEGEN: This method call is required by the Web Form Designer
'Do not modify it using the code editor.
InitializeComponent()
End Sub

#End Region

Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
'Put user code to initialize the page here

' Initialize the Connection object...
objConnection = New SqlConnection("Server=New\NetSdk;database=pubs;Integrated Security=sspi")

' Only bind the data the first time the page is built...
' Subsequent post backs will be to sort the data in the grid...
If Not (IsPostBack) Then
BindGrid("Last Name")

End If

End Sub

Public Sub BindGrid(ByVal strSortField As String)
' Declare objects...
Dim objDataSet As DataSet
Dim objDataAdapter As SqlDataAdapter

'Set the Sql String...
objDataAdapter = New SqlDataAdapter( _
"Select au_lname AS 'Last Name', au_fname AS 'First Name', " & _
"Title AS 'Book Title', price AS 'Retail Price' " & _
"From authors " & _
"JOIN titleauthor ON authors.au_id = titleauthor.au_id " & _
"JOIN titles ON titleauthor.title_id = titles.title_id " & _
"ORDER BY au_lname, au_fname", objConnection)

' Initialize the DataSet object and fill it...
objDataSet = New DataSet()
objDataAdapter.Fill(objDataSet, "Authors")

' Declare a DataView object, populate it,
' and sort the data in it...
Dim objDataView As DataView = _
objDataSet.Tables("Authors").DefaultView
objDataView.Sort = strSortField

' Bind the DataView object to the DataGrid control...
grdAuthors.DataSource = objDataView
grdAuthors.DataBind()

' Clean up...
End Sub

Private Sub grdAuthors_SortCommand(ByVal source As Object, ByVal e As System.Web.UI.WebControls.DataGridSortCommandEventArgs) Handles grdAuthors.SortCommand
' Bind the DataGrid using the sort column requested
BindGrid(e.SortExpression)
End Sub

Private Sub grdAuthors_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles grdAuthors.SelectedIndexChanged

End Sub
End Class