【发布时间】:2012-02-01 14:26:10
【问题描述】:
我遇到的问题是在检查该字段是否为空白之后,我希望程序停止,现在它正在继续检查用户名密码,即使该字段为空白并打印错误的用户名密码也是如此。我真的很陌生,所以请原谅缺乏知识
Private Sub ButtonOk_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ButtonOk.Click
Try
Dim con As New SqlConnection("Initial Catalog=stock;Data source=.;integrated security=true")
Dim ds1 As New DataSet
Dim da1 As New SqlDataAdapter("select * from login where Name='" & Trim(txtusername.Text) & "'and password='" & Trim(txtpassword.Text) & "'", con)
If txtpassword.Text.Length = 0 Then
MsgBox("Password or username feild left blank")
End If
If da1.Fill(ds1) Then
adminmain.Show()
Me.Close()
Else
MsgBox("Invalid Password or Username")
End If
Catch ex As Exception
MsgBox(ex.Message)
End Try
End Sub
【问题讨论】:
-
这是网络应用还是桌面应用? ASP.NET?表格? WPF?
-
@user1182892:欢迎使用 StackOverflow!您应该接受对您帮助最大的答案(通过单击旁边的复选标记)。您还可以投票给任何其他对您有帮助的答案。
标签: vb.net validation textbox