fooforever
New member
- Joined
- Mar 26, 2011
- Messages
- 1
- Programming Experience
- Beginner
Hi I'm looking for help with a small app I'm writing, im a total beginner so it could be very badly coded. Its a simple user verification app it does not need any great security it just needs to do the job. Its going to be used as a front end to open a database file. Im having problems with my query, it always returns a false value heres my code:
Any help would be greatly appreciated, the problem is that I allways get the Login Failed message box.
VB.NET:
Imports System.Data.SqlServerCe
Public Class Form1
Dim conn As SqlCeConnection = Nothing
Dim SearchResult As Boolean
Dim strSQL As String = "SELECT * FROM Users WHERE Username = '" & Username & "' AND Password = '" & Password & "'"
Dim objCmd As New SqlCeCommand(strSQL, conn)
Dim Username As String
Dim Password As String
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
If SearchResult = True Then
FileOpen(FreeFile, "database path", OpenMode.Append, OpenAccess.Default, OpenShare.Default)
Close()
Else
MsgBox("Login Failed")
End If
End Sub
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
Me.Close()
End Sub
Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click
Form2.Show()
End Sub
Public Sub Search()
conn = New SqlCeConnection("Data Source =.\Database1.sdf")
conn.Open()
If strSQL = True Then
SearchResult = True
End If
conn.Close()
End Sub
Public Sub TextBox1_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TextBox1.TextChanged
Username = TextBox1.Text
End Sub
Private Sub TextBox2_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TextBox2.TextChanged
Password = TextBox2.Text
End Sub
End Class