sqlLink.ConnectionString = "Provider = Microsoft.ACE.OLEDB.12.0; 데이터 원본 = 'C : \ Users \ will \ Documents \ Computing \ ComputingProjectDatabase.accdb';" sqlLink.Open() 시도 txtUsername.Text = ""그럼 있는 MsgBox ("당신은 사용자 이름을 입력하지 않았다!") 돌아 의 ElseIf txtPassword.Text = ""그럼 있는 MsgBox은 ("당신은을 입력하지 않은 경우 암호! ") 돌아 의 ElseIf txtPassword.Text <> txtPasswordConf.Text 그런 있는 MsgBox ("당신의 암호가 일치하지 않습니다! ") 반환 그렇지
VB Access 데이터베이스 중복 항목 방지 오류
Using sqlOrder As New OleDbCommand
Dim sqlCheck As New OleDbCommand
sqlCheck.CommandText = "SELECT count(*) FROM LoginSystem WHERE username = @username"
sqlCheck.Parameters.AddWithValue("@username", txtUsername.Text)
Dim oleRdr As OleDbDataReader
oleRdr = sqlCheck.ExecuteReader()
If oleRdr.HasRows = True Then
oleRdr.Read()
If oleRdr.Item(0) = 0 Then
sqlOrder.CommandText = "INSERT INTO LoginSystem ([Username], [Password], [PasswordConf]) VALUES ('" & txtUsername.Text & "','" & txtPassword.Text & "','" & txtPasswordConf.Text & "')"
sqlOrder.ExecuteNonQuery()
MsgBox("You have successfully registered, you can log in now!")
Else
MsgBox("Username is not currently available, please choose new username.")
End If
End If
End Using
End If
Catch ex As Exception
MsgBox("An error occurred:" & ex.Message)
End Try
sqlLink.Close()
Me.Close()
LoginScreen.Show()
End Sub
,
안녕하세요.> < 여기에 약간의 질문 만 있습니다. 로그인 데이터 집합의 복사본을 만들 때마다 (이 경우 사용자 이름은 헤더이고 암호는 Trentshop 임) 나는 "데이터가 저장되었습니다."라는 메시지와 함께 반환되며 데이터가 저장되지 않았다는 오류가 표시됩니다. 이미 사용 가능한 복제본이 있습니다.
이상하게도 "사용자 이름은 이미 사용 중입니다. 새 이름을 선택하십시오"라고 말하기를 선호합니다. ExceptDuplicateName 및 다른 유사한 유형으로 주변을 둘러 보았습니다. 그러나 어떤 이유로이 문제에 대해 내 머리를 터지게 할 수는 없습니다. 나는 누군가가이 문제를 해결하도록 도울 수 있다면 큰 도움이 될 것입니다. <
코드에이 코드를 통합했는데 제대로 작동하는 것처럼 보입니다. 그러나 "연결에 오류가 없습니다"가 표시됩니다. 전적으로 그것을 결코 경험하지 못했습니다. 매우 이상합니다. –
판독기 – 5uperdan
을 실행하기 전에 연결 개체에서 .Open() 메서드를 사용해야하고 oledbcommands의 연결 속성을 설정해야합니다. sqlCheck.Connection = sqlLink – 5uperdan