Newbie having trouble. Please help!!!!!
I am trying to set up a ASP.NET web site for the first time. I am using MS Vicual Web Developer 2005 Express with SQL Server 2005 Express.
I have set up a very basic bit of code to test connection to the database but I keep getting the error:
Cannot open database "xxx" requested by the login. The login failed.
Login failed for user 'LOUNGE\Greg'.
My page at the moment contains a button which call the code below:
Dim strSelectUsers As String = "SELECT * FROM users"
Dim strConnString As String = "data source=.\SQLEXPRESS; Initial Catalog=Hedgehog; Integrated Security=true; User Instance=true"
Dim connDB As New Data.SqlClient.SqlConnection(strConnString)
Dim daUsers As New Data.SqlClient.SqlDataAdapter(strSelectUsers, connDB)
Dim dsUsers As New Data.DataSet()
Dim dtUser As Data.DataTable
Dim drNewUser As Data.DataRow
Dim userDB As Data.SqlClient.SqlCommandBuilder = New Data.SqlClient.SqlCommandBuilder(daUsers)
connDB.Open()
daUsers.Fill(dsUsers, "dtUserTable")
connDB.Close()
dtUser = dsUsers.Tables("dtUserTable")
Try
drNewUser = dtUser.NewRow()
drNewUser(0) = "Fred"
drNewUser(1) = "Bloggs"
dtUser.Rows.Add(drNewUser)
Dim drModified As Data.DataRow() = dsUsers.Tables("dtUserTable").Select(Nothing, Nothing, Data.DataViewRowState.Added)
connDB.Open()
daUsers.Update(drModified)
Catch ex As Exception
MsgBox(ex.Message)
Throw ex
Finally
connDB.Close()
End Try
I have the database in the App_Data folder within the project.
I am assuming that the login being used to access the SQLEXPRESS engine is 'LOUNGE\Greg' and have made sure that is added with appropriate permissions using SQL Server Management Studio Express and have SQLEXPRESS listening on TCP and NP.
If anyone can give me an idea as to where I have gone wrong/missed something, your response would be greatfully received.
Greg
|