Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6657767
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T01:48:39+00:00 2026-05-26T01:48:39+00:00

Hello again and please forgive me for posting again. I do this when I

  • 0

Hello again and please forgive me for posting again. I do this when I realize I am having problem fixing it myself.

Please take a look at the code below. I was told by the individual that developed it originally that the code only adds the rows of data the user entered. In other words, there 5 rows of textboxes. A user can enter data into one row or into all 5 rows. If the user enters data into one row of textbox, that’s what gets inserted into the db.

I made some minor change to the code so that users can tell when a payment is made by check or cash payment.

Since I made that change, whether a user enters data into one row or all 5 rows, all 5 rows get inserted into the db.

How can I modify this code to ensure only rows entered get inserted?

I am really,really sorry for bothering you guys again and many thanks for all your help.

    For x = 1 To 5 Step 1
        dedval = obr.FindControl("ded" & CStr(x))
        chckvalflag = obr.FindControl("chck" & CStr(x))
        checkboxval = obr.FindControl("chckBox" & CStr(x))
        onetimeval = obr.FindControl("onetime" & CStr(x))
        chcknumval = obr.FindControl("chcknum" & CStr(x))
        multival = obr.FindControl("multi" & CStr(x))
        *If (chckvalflag.Text <> "" Or chckvalflag.Text <> "0") And Not checkboxval.Checked Then
            cashval = DirectCast(obr.FindControl("chck" & CStr(x)), TextBox).Text
            chckval = ""
            chcknumval.Text = "Cash Payment"
        Else
            chckval = DirectCast(obr.FindControl("chck" & CStr(x)), TextBox).Text
            chcknumval = obr.FindControl("chcknum" & CStr(x))
        End If*
        If dedval.Text <> "-1" And donatechoice.SelectedItem.Value <> "No" Then
            sql += "INSERT INTO Contribs (employee_id, charity_code, check_amt, chcknum, one_time, bi_weekly, cash, donate_choice, date_stamp) "
            sql += "VALUES ('" & Replace(employee_idLabel.Text, "'", "''") & "','" & Replace(dedval.SelectedValue, "'", "''") & "','" & Replace(chckval, "'", "''") & "','" & Replace(chcknumval.Text, "'", "''") & "','" & Replace(onetimeval.Text, "'", "''") & "','" & multival.Text & "','" & Replace(cashval, "'", "''") & "','" & Replace(donatechoice.SelectedItem.Value, "'", "''") & "','" & Replace(datestamp, "'", "''") & "');"
        End If
        If donatechoice.SelectedItem.Value = "No" Then
            x = 6
            sql += "INSERT INTO Contribs (employee_id, charity_code, check_amt, chcknum, one_time, bi_weekly, cash, donate_choice, date_stamp) "
            sql += "VALUES ('" & Replace(employee_idLabel.Text, "'", "''") & "','" & Replace(dedval.SelectedValue, "'", "''") & "','" & Replace(chckval, "'", "''") & "','" & Replace(chcknumval.Text, "'", "''") & "','" & Replace(onetimeval.Text, "'", "''") & "','" & Replace(multival.Text, "'", "''") & "','" & Replace(cashval, "'", "''") & "','" & Replace(donatechoice.SelectedItem.Value, "'", "''") & "','" & Replace(datestamp, "'", "''") & "');"
        End If
    Next
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-26T01:48:40+00:00Added an answer on May 26, 2026 at 1:48 am

    Just add some conditions to validate the data was entered into the inputs in each row.

    If Not String.IsNullOrEmpty(String.Concat(TextBox1.Text, TextBox2.Text, TextBox3.Text)) Then
        'insert logic here
    End If
    

    On a side note, I would suggest modifying the code to use parameters instead. The code is ripe for SQL-injection.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Can some one please tell me the problem with this code. I am reading
This code alert(Hello again! This is how we + \n + add line breaks
Hello I've runned in to a problem again that I can't solve on my
Hello can anybody solve this please I'm creating the object in the action class
please tell me theres a way around this... $my_var = 'hello'; class Test{ private
Hello and excuse me again I have the next problem: I am using fbgraph
Hello again ladies and gents! OK, following on from my other question on ASP.NET
Hello again Stackoverflow people! Assume I have these words: smartphones, smartphone I want to
Hello I am working with a simulator that uses rcS scripts to boot, this
Hello everyone I been trying get php uploader working but having a lot of

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.