我遇到的問題是檢查後,如果字段是空白的,我希望程序停止在那,現在它會繼續並檢查用戶名密碼,即使該字段爲空,打印錯誤的用戶名密碼我真的很新的這所以請原諒缺乏從功能知識在vb.net文本框多重驗證
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?的WinForms? WPF? – DOK 2012-02-01 14:28:34
@ user1182892:歡迎使用StackOverflow!您應該接受最能幫助您的答案(通過點擊旁邊的複選標記)。你也可以upvote任何其他幫助你的答案。 – 2012-02-01 15:13:08