desperateboy
Active member
- Joined
- Dec 11, 2007
- Messages
- 30
- Programming Experience
- Beginner
hi friends,
i am making login form and a little error creating problem.giving error incorrect syntax near keyword user.i have made table of user and wanna fetch user name and password.
Plz help to solve.
i am making login form and a little error creating problem.giving error incorrect syntax near keyword user.i have made table of user and wanna fetch user name and password.
Plz help to solve.
VB.NET:
Imports System.Data.SqlClient
Imports System.Data
Public Class Form1
Dim usrid As Integer
Dim timCount As Integer
Dim i As Integer
Dim cmd As New SqlCommand
Dim dr As SqlDataReader
Dim hasrows As Boolean = False
Dim valid As Boolean
Dim LogID As Integer
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
sUNAME = TextBox1.Text
sPass = TextBox2.Text
Try
conn.Open()
cmd = New SqlCommand("select uname,upwd from user where uname = '" & Trim(TextBox1.Text) & "' and upwd = '" & Trim(TextBox2.Text) & "'", conn)
dr = cmd.ExecuteReader
If dr.HasRows Then
While dr.Read()
If sPass = dr.Item("upwd") Then
'sPass = dr.Item("upwd")
'sRight = dr.Item("ur")
valid = True
End If
End While
hasrows = True
End If
dr.Close()
Catch ex As Exception
MsgBox(ex.Message)
Finally
conn.Close()
cmd = Nothing
End Try
i = i + 1
If valid = True Then
Me.Hide()
MDIParent1.Show()
ElseIf i >= 3 Then
MsgBox("Sorry, you have lost your time.....", MsgBoxStyle.Exclamation)
ElseIf hasrows = False Then
MsgBox("Invalid User or Password, Try Again", vbCritical, "Login Error")
TextBox1.SelectionStart = 0
TextBox1.SelectionLength = Len(TextBox1.Text)
TextBox1.Focus()
End If
End Sub
Last edited by a moderator: