15-05-18, 11:17 PM
ده الكود اللى استخدمته
Private Sub LoginButton_Click(sender As Object, e As EventArgs) Handles LoginButton.Click
Try
Dim con As New SqlConnection("Data source=.;Initial Catalog=ChurchMembership;Integrated Security=True")
If TextBoxUsername.Text = "" Then
MsgBox("You Must Enter The Username", MsgBoxStyle.Exclamation, "Error")
End If
If TextBoxPassword.Text = "" Then
MsgBox("You Must Enter The Password", MsgBoxStyle.Exclamation, "Error")
End If
Dim Str As String = "select * from Users where Username =" & TextBoxUsername.Text & "and Password=" & TextBoxPassword.Text & ""
Dim da As New SqlDataAdapter(Str, Con)
Dim ds As New DataSet
da.Fill(ds)
If ds.Tables(0).Rows.Count > 0 Then
Me.Hide()
MdiParent.Show()
End If
Catch ex As Exception
MsgBox(ex.Message)
End Try
End Sub
وعند التنفيذ تظهر لى رسالة
Incorrect syntax near 'Password'
Private Sub LoginButton_Click(sender As Object, e As EventArgs) Handles LoginButton.Click
Try
Dim con As New SqlConnection("Data source=.;Initial Catalog=ChurchMembership;Integrated Security=True")
If TextBoxUsername.Text = "" Then
MsgBox("You Must Enter The Username", MsgBoxStyle.Exclamation, "Error")
End If
If TextBoxPassword.Text = "" Then
MsgBox("You Must Enter The Password", MsgBoxStyle.Exclamation, "Error")
End If
Dim Str As String = "select * from Users where Username =" & TextBoxUsername.Text & "and Password=" & TextBoxPassword.Text & ""
Dim da As New SqlDataAdapter(Str, Con)
Dim ds As New DataSet
da.Fill(ds)
If ds.Tables(0).Rows.Count > 0 Then
Me.Hide()
MdiParent.Show()
End If
Catch ex As Exception
MsgBox(ex.Message)
End Try
End Sub
وعند التنفيذ تظهر لى رسالة
Incorrect syntax near 'Password'