Announcement

Collapse

The Alpha Software Forum Participation Guidelines

The Alpha Software Forum is a free forum created for Alpha Software Developer Community to ask for help, exchange ideas, and share solutions. Alpha Software strives to create an environment where all members of the community can feel safe to participate. In order to ensure the Alpha Software Forum is a place where all feel welcome, forum participants are expected to behave as follows:
  • Be professional in your conduct
  • Be kind to others
  • Be constructive when giving feedback
  • Be open to new ideas and suggestions
  • Stay on topic


Be sure all comments and threads you post are respectful. Posts that contain any of the following content will be considered a violation of your agreement as a member of the Alpha Software Forum Community and will be moderated:
  • Spam.
  • Vulgar language.
  • Quotes from private conversations without permission, including pricing and other sales related discussions.
  • Personal attacks, insults, or subtle put-downs.
  • Harassment, bullying, threatening, mocking, shaming, or deriding anyone.
  • Sexist, racist, homophobic, transphobic, ableist, or otherwise discriminatory jokes and language.
  • Sexually explicit or violent material, links, or language.
  • Pirated, hacked, or copyright-infringing material.
  • Encouraging of others to engage in the above behaviors.


If a thread or post is found to contain any of the content outlined above, a moderator may choose to take one of the following actions:
  • Remove the Post or Thread - the content is removed from the forum.
  • Place the User in Moderation - all posts and new threads must be approved by a moderator before they are posted.
  • Temporarily Ban the User - user is banned from forum for a period of time.
  • Permanently Ban the User - user is permanently banned from the forum.


Moderators may also rename posts and threads if they are too generic or do not property reflect the content.

Moderators may move threads if they have been posted in the incorrect forum.

Threads/Posts questioning specific moderator decisions or actions (such as "why was a user banned?") are not allowed and will be removed.

The owners of Alpha Software Corporation (Forum Owner) reserve the right to remove, edit, move, or close any thread for any reason; or ban any forum member without notice, reason, or explanation.

Community members are encouraged to click the "Report Post" icon in the lower left of a given post if they feel the post is in violation of the rules. This will alert the Moderators to take a look.

Alpha Software Corporation may amend the guidelines from time to time and may also vary the procedures it sets out where appropriate in a particular case. Your agreement to comply with the guidelines will be deemed agreement to any changes to it.



Bonus TIPS for Successful Posting

Try a Search First
It is highly recommended that a Search be done on your topic before posting, as many questions have been answered in prior posts. As with any search engine, the shorter the search term, the more "hits" will be returned, but the more specific the search term is, the greater the relevance of those "hits". Searching for "table" might well return every message on the board while "tablesum" would greatly restrict the number of messages returned.

When you do post
First, make sure you are posting your question in the correct forum. For example, if you post an issue regarding Desktop applications on the Mobile & Browser Applications board , not only will your question not be seen by the appropriate audience, it may also be removed or relocated.

The more detail you provide about your problem or question, the more likely someone is to understand your request and be able to help. A sample database with a minimum of records (and its support files, zipped together) will make it much easier to diagnose issues with your application. Screen shots of error messages are especially helpful.

When explaining how to reproduce your problem, please be as detailed as possible. Describe every step, click-by-click and keypress-by-keypress. Otherwise when others try to duplicate your problem, they may do something slightly different and end up with different results.

A note about attachments
You may only attach one file to each message. Attachment file size is limited to 2MB. If you need to include several files, you may do so by zipping them into a single archive.

If you forgot to attach your files to your post, please do NOT create a new thread. Instead, reply to your original message and attach the file there.

When attaching screen shots, it is best to attach an image file (.BMP, .JPG, .GIF, .PNG, etc.) or a zip file of several images, as opposed to a Word document containing the screen shots. Because Word documents are prone to viruses, many message board users will not open your Word file, therefore limiting their ability to help you.

Similarly, if you are uploading a zipped archive, you should simply create a .ZIP file and not a self-extracting .EXE as many users will not run your EXE file.
See more
See less

Trying to Update A Record in SQL

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Trying to Update A Record in SQL

    Hi all,
    I'm trying to update a MySQL record and I keep getting an error at my sqlInsert line saying invalid entry handle. I'm sure its a syntax thing. Could you point me in the right direction please?

    As always,
    Thanks in Advance!


    sqlInsert="UPDATE appdata1 SET" +
    "majormed = " + :f1 + "," +
    "accidentinsur = " + :f2 + "," +
    "dental = " + :f3 +
    "WHERE add_email = " + :vUser

    flagResult = cn.open("::Name::ABLEDB")
    if flagResult = .f. then
    e.javascript = "alert('Error : could not connect to the database - contact support');"
    end
    end if

    flag = cn.Execute(sqlInsert)
    if flag = .f. then
    cn.Close()
    msg = "Could not delete record. Error reported was: " + cn.CallResult.text
    msg = js_escape(msg)
    jscmd = "alert('" + msg + "');"
    exit function
    end if
    Rapid Development, Training, Support
    http://data2web.network
    903-740-2549

  • #2
    Re: Trying to Update A Record in SQL

    Is this thread related?

    http://msgboard.alphasoftware.com/al...te-Help-Please

    I don't see how the arguments are incorporated into the sql statement...

    There should be an example of using arguments..
    Al Buchholz
    Bookwood Systems, LTD
    Weekly QReportBuilder Webinars Thursday 1 pm CST

    Occam's Razor - KISS
    Normalize till it hurts - De-normalize till it works.
    Advice offered and questions asked in the spirit of learning how to fish is better than someone giving you a fish.
    When we triage a problem it is much easier to read sample systems than to read a mind.

    Comment


    • #3
      Re: Trying to Update A Record in SQL

      Thank you Al
      My variables are logical 0/1 for yes/no

      dim f1 as c = e.datasubmitted.majormed
      dim f2 as c = e.datasubmitted.accidentinsur
      dim f3 as c = e.datasubmitted.dental
      dim vUser as c = e.datasubmitted.email
      Rapid Development, Training, Support
      http://data2web.network
      903-740-2549

      Comment


      • #4
        Re: Trying to Update A Record in SQL

        I suggest that you use the debug(1) function to see what is in the sqlinsert variable.

        or use the interactive window.

        a couple of potential issues are

        1. you need a space between SET and majormed
        2. quotes around a character value

        sqlInsert="UPDATE appdata1 SET " +
        "majormed = " + :f1 + "," +
        "accidentinsur = " + :f2 + "," +
        "dental = " + :f3 +
        "WHERE add_email = ' " + :vUser +" ' "
        Al Buchholz
        Bookwood Systems, LTD
        Weekly QReportBuilder Webinars Thursday 1 pm CST

        Occam's Razor - KISS
        Normalize till it hurts - De-normalize till it works.
        Advice offered and questions asked in the spirit of learning how to fish is better than someone giving you a fish.
        When we triage a problem it is much easier to read sample systems than to read a mind.

        Comment


        • #5
          Re: Trying to Update A Record in SQL

          Two options here:
          1) you use variables, in which case you don't need the ":":
          Code:
          dim f1 as c = e.datasubmitted.majormed
          dim f2 as c = e.datasubmitted.accidentinsur
          dim f3 as c = e.datasubmitted.dental
          dim vUser as c = e.datasubmitted.email 
          sqlInsert="UPDATE appdata1 SET " +
          "majormed = " + f1 + "," +
          "accidentinsur = " + f2 + "," +
          "dental = " + f3 +
          " WHERE add_email = '" + vUser +"'"
          or more simply,
          Code:
          dim f1 as c = e.datasubmitted.majormed
          dim f2 as c = e.datasubmitted.accidentinsur
          dim f3 as c = e.datasubmitted.dental
          dim vUser as c = e.datasubmitted.email 
          sqlInsert="UPDATE appdata1 SET majormed = " + f1 + ", accidentinsur = " + f2 + ", dental = " + f3 + " WHERE add_email = '" + vUser + "'"
          or 2) use arguments:
          Code:
          dim args as sql::arguments
          args.add("f1",e.datasubmitted.majormed)
          args.add("f2",e.datasubmitted.accidentinsur)
          args.add("f3",e.datasubmitted.dental)
          args.add("vUser",e.datasubmitted.email)
          sqlInsert="UPDATE appdata1 SET majormed = :f1, accidentinsur = :f2, dental = :f3 WHERE add_email = :vUser"
          
          cn.Execute(sqlInsert,args)
          Last edited by christappan; 12-08-2012, 11:58 PM.

          Comment


          • #6
            Re: Trying to Update A Record in SQL

            OMG! Chris you are a saint!
            I have literally spent 12+ hours working on this today and I am so grateful that you took the time to help!
            I plugged in the code from box 1B above and it worked without modification. It was sooo nice to finally see some 1's in my record instead of default 0's. Once I get my code cleaned up I will post the whole thing for others to learn from.

            Again,
            Thank You!
            Rapid Development, Training, Support
            http://data2web.network
            903-740-2549

            Comment


            • #7
              Re: Trying to Update A Record in SQL

              As promised, here is my working code for an MySQL Update Record using a Dialog2 Control:

              function afterDialogValidate as v (e as p)
              'debug(1)

              dim cn as SQL::Connection
              dim flagResult as c
              dim msg as c
              dim jscmd as c
              dim f1 as c = e.datasubmitted.majormed
              dim f2 as c = e.datasubmitted.accidentinsur
              dim f3 as c = e.datasubmitted.dental
              dim f4 as c = e.datasubmitted.hospitalconfine
              dim f5 as c = e.datasubmitted.life
              dim f6 as c = e.datasubmitted.cancer
              dim f7 as c = e.datasubmitted.vision
              dim f8 as c = e.datasubmitted.shortmed
              dim f9 as c = e.datasubmitted.other
              dim f10 as c = e.datasubmitted.besttimecallinsurance
              dim f11 as c = e.datasubmitted.gen_applyb4
              dim f12 as c = e.datasubmitted.gen_dateapplied
              dim f13 as c = e.datasubmitted.gen_empb4
              dim f14 as c = e.datasubmitted.gen_weed
              dim f15 as c = e.datasubmitted.gen_quit
              dim f16 as c = e.datasubmitted.gen_car
              dim f17 as c = e.datasubmitted.gen_childcare
              dim f18 as c = e.datasubmitted.gen_workus
              dim f19 as c = e.datasubmitted.gen_ovr18
              dim f20 as c = e.datasubmitted.gen_criminal
              dim f21 as c = e.datasubmitted.gen_crimexplain
              dim f22 as c = e.datasubmitted.gen_felony
              dim f23 as c = e.datasubmitted.gen_felonexplain
              dim f24 as c = e.datasubmitted.gen_accident
              dim f25 as c = e.datasubmitted.genaccidentexplain
              dim f26 as c = e.datasubmitted.gen_30d
              dim f27 as c = e.datasubmitted.gen_meds
              dim f28 as c = e.datasubmitted.gen_dob
              dim f30 as c = e.datasubmitted.gen_sex
              dim f31 as c = e.datasubmitted.gen_dateavail
              dim sInsert as c ="UPDATE appdata1 SET majormed = " + f1 + ", accidentinsur = " + f2 + ", dental = " + f3 + ", hospitalconfine = " + f4 + ", life = " + f5 + ", cancer = " + f6 + ", vision = " + f7 + ", shortmed = " + f8 + ", other = " + f9 + ", besttimecallinsurance = " + f10 + ", gen_applyb4 = " + f11 + ", gen_dateapplied = " + f12 + ", gen_empb4 = " + f13 + ", gen_weed = " + f14 + ", gen_quit = " + f15 + ", gen_car = " + f16 + ", gen_childcare = " + f17 + ", gen_workus = " + f18 + ", gen_ovr18 = " + f19 + ", gen_criminal = " + f20 + ", gen_crimexplain = " + f21 + ", gen_felony = " + f22 + ", gen_felonexplain = " + 23 + ", gen_accident = " + f24 + ", genaccidentexplain = " + f25 + ", gen_30d = " + f26 + ", gen_meds = " + f27 + ", gen_dob = " + f28 + ", gen_sex = " + f29 + ", gen_dateavail = " + f30 + " WHERE add_socialsecurity = '" + vUser + "'"

              flagResult = cn.open("::Name::ABLEDB")
              if flagResult = .f. then
              e.javascript = "alert('Error : could not connect to the database - contact support');"
              end
              end if

              flag = cn.Execute(sInsert)
              if flag = .f. then
              cn.Close()
              msg = "Could not delete record. Error reported was: " + cn.CallResult.text
              msg = js_escape(msg)
              jscmd = "alert('" + msg + "');"
              exit function
              end if

              cn.close()

              end function
              Rapid Development, Training, Support
              http://data2web.network
              903-740-2549

              Comment


              • #8
                Re: Trying to Update A Record in SQL

                You really should use arguments in your script because your entries come from a data-entry form and is subject to "sql injection" errors. Here is my shot, minus some error checking.

                dim cn as sql::Connection
                dim args as sql::Arguments
                dim vSql as c = <<%txt%
                UPDATE appdata1 SET
                majormed =:majormed
                accidentinsur =:accidentinsur
                dental =:dental
                %txt%
                args.add("majormed", e.datasubmitted.majormed)
                args.add("accidentinsur",e.datasubmitted.accidentinsur)
                args.add("dental",e.datasubmitted.dental)

                cn.open("::Name::ABLEDB") '== I don't always error check this because it is unlikely to fail, and the execute function below will catch the error

                if cn.execute(vSql,args) = .f.
                '==your error reporting routine here
                cn.close()
                end if
                cn.close()
                Steve Wood
                Join the ALPHA DEVELOPERS NETWORK
                There is no Cloud. It's just someone else's computer.
                Web - Mobile - Hosting - Products - Frameworks - Developer Resources
                AlphaToGo | IADN (100% Alpha Anywhere Websites)

                Comment


                • #9
                  Re: Trying to Update A Record in SQL

                  ^ +1
                  Args are really easy to use once you get used to them (none of that "SELECT" +var+ " stuff that throws you off in long statements) and more secure.

                  Comment

                  Working...
                  X