allora questo è il mio code...
codice:
Private Sub Check(ByVal sender As Object, ByVal e As System.EventArgs)
Dim sql As New MySqlCommand("Select * from utenti WHERE username = '" & username.Text & "' ", myConnection)
Dim qq As MySqlDataReader
qq = sql.ExecuteScalar
Response.Write(username.Text)
If username.Text = qq("username") Then
Response.Write("HAI RAGIONE")
Else
Response.Write("asd")
End If
myConnection.Close()
End Sub
questo l'errore
Object reference not set to an instance of an object.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details: System.NullReferenceException: Object reference not set to an instance of an object.
Source Error:
Line 14: qq = sql.ExecuteScalar
Line 15: Response.Write(username.Text)
Line 16: If username.Text = qq("username") Then
Line 17: Response.Write("HAI RAGIONE")
Line 18: Else
Ho letto che per estrarre un record solo non server fare sql.ExecuteReader, ma basta un ExecuteScalar
sembra però che nn funzioni con entrambi
sapete dirmi dove sbaglio?
grazie 1000