0
사용자가 누르는 것을 허용하려합니다. 을 입력하여 로그인하십시오. 그러나 모든 종류의 유효성 검사를 통해 데이터베이스 연결이 있습니다. 이미 가지고있는 코드 내에서 코드를 통합 할 수 있습니까?데이터베이스 연결로 클릭시 입력 누르기
저는 지금 몇 시간 동안이 작업을 해왔고, 저를 미치게했습니다. 데이터베이스 연결이 없어도 작동하지만 기존 코드로 작업해야합니다.
누군가 내가이 작업을 수행 할 수있는 방법을 알려주시겠습니까? 당신이 당신의 경우 조건 변경해야하는 모든
Try
Dim objconnection As SqlConnection = New SqlConnection("Data Source=(LocalDB)\v11.0;AttachDbFilename=C:\Users\Cara\Documents\Visual Studio 2012\Projects\Online Portal Solutions\Online Portal Solutions\Online Portal Solutions Database.mdf;Integrated Security=True")
objconnection.Open()
Dim SelectStmt As String = "SELECT * FROM [1InnospecLogIn] WHERE Username='" & txt_cusername.Text & "' COLLATE SQL_Latin1_General_CP1_CS_AS AND Password='" & txt_cpassword.Text & "' COLLATE SQL_Latin1_General_CP1_CS_AS ;"
Dim objcommand As SqlCommand = New SqlCommand(SelectStmt, objconnection)
Dim reader As SqlDataReader = objcommand.ExecuteReader
If reader.Read Then
If txt_cpassword.Text <> reader("Password").ToString And txt_cusername.Text <> reader("Username").ToString Then
frm_2custhome.Show()
Me.Hide()
txt_cusername.Text = ""
txt_cpassword.Text = ""
combocustomer.SelectedIndex = -1
txt_cusername.Select()
End If
Else
Static count As Integer = 0
Dim prompt As DialogResult = MessageBox.Show("Please enter valid credentials.", "Login Error",
MessageBoxButtons.RetryCancel, MessageBoxIcon.Warning)
Select Case prompt
Case Windows.Forms.DialogResult.Retry
txt_cusername.Text = ""
txt_cpassword.Text = ""
combocustomer.SelectedIndex = -1
txt_cusername.Select()
count += 1
If count = 3 Then
MessageBox.Show("High value of failed login attempts." & vbCrLf & "Application will be terminated for security reasons.", "Error",
MessageBoxButtons.OK, MessageBoxIcon.Stop)
End
End If
Case Windows.Forms.DialogResult.Cancel
Application.Exit()
End Select
End If
objconnection.Close()
Catch ex As Exception
End Try
질문에 제공 한 코드는 함수에서 그 코드를 유지합니다. 그런 다음 폼의 디자인보기로 이동 -> 입력 할 기능이있는 텍스트 상자 선택 -> 속성 창으로 이동 이벤트 탭 선택 -> KeyDown 이벤트를 두 번 클릭하십시오. 위의 코드를 사용하여 인증 함수를 호출하십시오. –