Greetings everyone i really need some help about this error.

If (maleRbtn.Checked = True) Then
            gender = 0
        ElseIf (femaleRbtn.Checked = True) Then
            gender = 1
        End If

        If (dietRbtn.Checked = True) Then
            purpose = 0
        ElseIf (BDrbtn.Checked = True) Then
            purpose = 1
        End If
        Try
            sqlCmd = New SqlCommand("INSERT INTO registered_cust_tbl([customer_Id],[customer_fname], [customer_lname], [customer_DoB], [customer_Contact], [customer_Email], " & _
                                    " [customer_Address], [customer_Gender], [customer_Ailments], [customer_Username], [customer_Password], " & _
                                    " [customer_Secret_Question],[customer_Secret_Answer],[customer_Purpose]) " & _
                                    " VALUES ('" & firstNameTb.Text.Trim & "', '" & lastNameTb.Text.Trim & "', '" & DoBdtp.Text & "', '" & customerMPNo.Text & "', '" & _
                                                   emailTb.Text.Trim & "', '" & addressRtb.Text.Trim & "', '" & gender & "', '" & ailmentstxtBx.Text.Trim & "', '" & _
                                                   usernameTF.Text.Trim & "', '" & passwordTF.Text & "', '" & SecQuesBox.Text & "', '" & SecAnsBox.Text.Trim & "', '" & _
                                                   purpose & "' ", getConnect())

            sqlCmd.ExecuteNonQuery()
            getConnect.Close()
        Catch ex As Exception
            MsgBox(ex.Message)
            MsgBox(sqlCmd)
        End Try

I really appriciate your help thanks in advance

Recommended Answers

All 3 Replies

Looks like you're missing a ")", try this,

sqlCmd = New SqlCommand("INSERT INTO registered_cust_tbl([customer_Id],[customer_fname],
                        [customer_lname], [customer_DoB], [customer_Contact], [customer_Email],
                        " & " [customer_Address], [customer_Gender], [customer_Ailments],
                        [customer_Username], [customer_Password], " & " [customer_Secret_Question]
                        ,[customer_Secret_Answer],[customer_Purpose]) " & " 
                        VALUES ('" & firstNameTb.Text.Trim & "', '" & lastNameTb.Text.Trim & "'
                        , '" & DoBdtp.Text & "', '" & customerMPNo.Text & "', '" & 
                        emailTb.Text.Trim & "', '" & addressRtb.Text.Trim & "', '" & gender & 
                        "', '" & ailmentstxtBx.Text.Trim & "', '" & usernameTF.Text.Trim & "'
                        , '" & passwordTF.Text & "', '" & SecQuesBox.Text & "', '" & 
                        SecAnsBox.Text.Trim & "', '" & purpose & "' "), getConnect())

lol thanks.. i guess i really have a bad eye sight. Thanks again :D.

A minor suggestion. Assuming you are using radio buttons then you can simplify your code because if (for example) the male button is not selected then the famale buttom must be selected. So instead of

If (maleRbtn.Checked = True) Then
    gender = 0
ElseIf (femaleRbtn.Checked = True) Then
    gender = 1
End If

you can write

gender = IIF(makeRbtn.Checked, 0, 1)

or if you have defined consts for MALE and FEMALE you can do

gender = IIF(makeRbtn.Checked, MALE, FEMALE)

which is clearer.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.