When I run my code I get the following exception:
The timeout period elapsed prior to obtaining a connection from the pool. This may have occurred because all pooled connections were in use and max pool size was reached
Does anyone know what is going on with this error and how I can solve it?
Dim cmd As New SqlCommand
Dim myreader As SqlClient.SqlDataReader
Dim objconnection As New SqlConnection()
objconnection = New SqlConnection("Data Source=.;Initial Catalog=AP6;Integrated Security=True")
objconnection.Open()
Dim query As String
query = "select * from students where username='" + txt_user.Text + "' AND password='" + txt_password.Text + "'"
Dim objcommand As New SqlCommand(query, objconnection)
myreader = objcommand.ExecuteReader()
If myreader.Read() Then
txt_user.Text = myreader("username")
txt_password.Text = myreader("password")
lbl_st_id.Text = myreader("st_id").ToString()
Response.Redirect("students_tasks.aspx?id=" + myreader("st_id").ToString())
Else
lbl_error3.Visible = True
End If
myreader.Close()
objconnection.Close()
End If