akekrakbar
Programmer
Hello!
Im trying to do a simple login with databaseinteractivity. But when i try to get data wich doesn´t come from a column in the db but rather a function i get an error message. This is the code:
This is the error message:
What am I doing wrong?
Im trying to do a simple login with databaseinteractivity. But when i try to get data wich doesn´t come from a column in the db but rather a function i get an error message. This is the code:
Code:
Sub klick_login(Src as object, E as EventArgs )
Dim cn as new OLEDBConnection(dbPath)
Dim dr as OleDbDataReader
Dim strSql as String
strSql = "SELECT COUNT() as total FROM medlemmar WHERE anvandarnamn='" & txtAnvandarnamn.text & "' AND losenord='" & txtLosenord.text & "'"
Dim cm = New OLEDBCommand(strSQL, cn)
cn.Open()
dr=Cm.ExecuteReader(CommandBehavior.CloseConnection)
dr.read()
cn.Close()
lblTest.text = dr("total")
End Sub
This is the error message:
Code:
Exception Details: System.InvalidOperationException: No data exists for the row/column.
Source Error:
Line 26: lblTest.text = dr("total")
What am I doing wrong?