I am sorry, I realized that I did not provided enough information. Hereby some more detail:
I am using VB, not C. Unfortunately I can't use ASP.NET 3.5 as my provider only supports version 2.0. I am using Visual Studio 2005 to put my website together.
This is the code that I used so far but I have the feeling that I am doing something way to complicated. Afterall,k I am only trying to retrieve one single string value out of a database using a SELECT command:
Imports System.Data.SqlClient
Dim connections As ConnectionStringSettingsCollection = _
ConfigurationManager.ConnectionStrings
Dim ConnectionString
For Each connection As ConnectionStringSettings In connections
If connection.Name = "ServerListConnectionString" Then
ConnectionString = connection.ConnectionString
Exit For
End If
NextDim queryString As String = _
"SELECT [BesrApproved] FROM [manualInfo] WHERE ([name] = @name)"Using connection As New SqlConnection(ConnectionString)
Dim command As New SqlCommand(queryString, connection)command.Parameters.AddWithValue("@Name", TextBoxServerName.Text)
connection.Open()
Dim reader As SqlDataReader = command.ExecuteReader()
' Call Read before accessing data.While reader.Read()
LabelUserName.Text = (reader.GetBoolean(0))
End While
' Call Close when done reading.
reader.Close()