Protected Sub login_btn_Click(sender As Object, e As EventArgs) Handles login_btn.Click
Dim connString As String
Dim connection As SqlConnection
Dim command As SqlCommand
Dim sql As String
connString = "Data Source=.\SQLExpress;Initial Catalog=Suivi_Invst;Integrated Security=True"
sql = "select NET_ID, Password from User"
connection = New SqlConnection(connString)
Try
connection.Open()
command = New SqlCommand(sql, connection)
Dim sqlReader As SqlDataReader = command.ExecuteReader()
While sqlReader.Read()
If (Password.Text = sqlReader("Password") And NET_ID.Text = sqlReader("NET_ID")) Then
Response.Redirect("Creation.aspx")
End If
End While
sqlReader.Close()
command.Dispose()
connection.Close()
Catch ex As Exception
MsgBox("Can not open connection ! ")
End Try
End Sub
I always get the msg box saying that connection can noy be established.
I tried to open SQL Server Management Studio at the same time the code running but I didn't anything.
Aucun commentaire:
Enregistrer un commentaire