information already on file problem - Reader.HasRows

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • ashes
    New Member
    • Jul 2008
    • 7

    information already on file problem - Reader.HasRows

    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(cm dText, myConnection)

    Dim reader As OleDbDataReader

    reader = command.Execute Reader

    Dim autonumber As Integer



    Dim check As Integer

    check = Microsoft.Visua lBasic.Val("Cus tomerID")

    If check < Microsoft.Visua lBasic.Val("Cus tomerID") Then



    autonumber = check

    End If



    If reader.HasRows Then

    Me.Registration Message.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(cm dText, myConnection)

    command.Execute NonQuery()

    Response.Redire ct("Registratio nApproved.aspx" )


    End If

    End Using

    can anyone help me please?
Working...