I want to loop through my table and extract a UserName that corresponds with the UserName typed in a text box using the execute scarlar method.
If it's there then i call a message and exit the sub, if its not there then i add the User.
VB Code:
Public Shared Function LookUp( ByVal strSQL As String) As String Dim strValue As String = "" Dim myConn As OleDbConnection = New OleDbConnection(strAccessConn) Dim myCommand As New OleDbCommand(strSQL, myConn) Try myConn.Open() strValue = CStr(myCommand.ExecuteScalar()) 'Option strict is on myConn.Close() Catch ex As Exception MsgBox("Error:" & ex.Message) End Try Return strValue End Function
Here is my SQL
VB Code:
Dim strUserName as string="SELECT UserName FROM Users WHERE(UserName='" & Me.tbUserName.text.Trim() & "')"
My Execute scalar returns a string but i cant get the string when i call it like this. It Returns an empty messagebox
VB Code:
MessageBox.Show(LookUp(strUserName).toUpper)




Reply With Quote