Hi,
i created a register form on a website. The information from the form has to go in the customer table in a database in MS Access.
the information is going into the table perfectly. however, if i don't want a repeat of information and the system checks to see if the user is already in the database i get an error. it's either i get the error message "The user name you entered is already on file." all the time
or if i put "Not reader.HasRows" then the information is inputted into the database no matter if it is already there.
Dim cmdText As String = "SELECT * FROM Customer"
Dim command As OleDbCommand
command = New OleDbCommand(cmdText, myConnection)
Dim reader As OleDbDataReader
reader = command.ExecuteReader
Dim autonumber As Integer
Dim check As Integer
check = Microsoft.VisualBasic.Val("CustomerID")
If check < Microsoft.VisualBasic.Val("CustomerID") Then
autonumber = check
End If
If reader.HasRows Then
Me.RegistrationMessage.Text = "The user name you entered is already on file."
reader.Close()
Return
Else
cmdText = "INSERT INTO Customer (FirstName, LastName, Address, Country, PhoneNo, Email, UserName, [Password]) VALUES ('" + FirstName.Text + "','" + LastName.Text + "','" + Address.Text + "','" + Country.Text + "','" + PhoneNo.Text + "','" + Email.Text + "','" + UserName1.Text + "','" + Password1.Text + "')"
command = New OleDbCommand(cmdText, myConnection)
command.ExecuteNonQuery()
Response.Redirect("RegistrationApproved.aspx")
End If
End Using
can anyone help me please?