Alpha Software Mobile Development Tools:   Alpha Anywhere    |   Alpha TransForm subscribe to our YouTube Channel  Follow Us on LinkedIn  Follow Us on Twitter  Follow Us on Facebook

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

SQL Select Argument Passing Issue

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

    SQL Select Argument Passing Issue

    I am using QODBC to select and also insert records in a QuickBooks company data file.

    Using XBasic, I can connect and retrieve what I need. For example, the following pertinent code excerpt works as expected:

    ......
    sqlStatement = <<%sql%
    SELECT CompanyName, BillAddressCity, BillAddressState, BillAddressPostalCode FROM Customer WHERE CompanyName LIKE '5AM Partners%'
    '%sql%
    .....

    Here, I am looking for a CompanyName that starts with 5AM Partners... from the Customer table. With the rest of the code not shown, it works fine.

    But, I would like to pass as an argument to the SQL the CompanyName to search by. So, this is what I think should work:

    dim args as sql::arguments
    args.set("TestName","'5AM Partners%'")
    sqlStatement = <<%sql%
    SELECT CompanyName, BillAddressCity, BillAddressState, BillAddressPostalCode FROM Customer WHERE CompanyName LIKE :TestName
    %sql%

    This doesn't work - it returns an error dialog box saying: An argument value was reference in the SQL query, but no argument list was provided.

    Would any one know the correct syntax for this?

    Thanks a bunch!

    UPDATE:

    The following code does work:

    temp1 = "'5AM Partners%'"
    sqlStatement = "SELECT CompanyName, BillAddressCity FROM Customer WHERE CompanyName LIKE " + temp1

    So, is it a problem with the <<%sql%.....%sql% being used with args.set(), perhaps at the end of the line?

    Curious minds want to know...
    Last edited by ecsaltz; 11-12-2007, 04:53 PM.
    Eugene Saltz, QuickBooks Certified ProAdvisor, Microsoft Certified Systems Engineer
    Saltz Consulting LLC
    [email protected]
    www.saltzconsulting.com
    QuickBooks Sales & Support - Advanced Certified QuickBooks ProAdvisors - Enterprise Solution Providers

    #2
    Re: SQL Select Argument Passing Issue

    Gene

    I used action scripting to come up with this code.

    Alpha DAO select and worked through the genie, testing along the way.

    Use this code and modify it to your needs. It worked on my data...

    I'm not sure where your code is hanging up.... But I thought I'd pass along code that does work. Maybe you can reverse engineer the problem from there.
    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.
    "Make it as simple as possible, but not simpler."
    Albert Einstein

    http://www.iadn.com/images/media/iadn_member.png

    Comment


      #3
      Re: SQL Select Argument Passing Issue

      Gene

      instead of
      args.set("TestName","'5AM Partners%'")


      try taking off the single quotes....

      args.set("TestName","5AM Partners%")
      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.
      "Make it as simple as possible, but not simpler."
      Albert Einstein

      http://www.iadn.com/images/media/iadn_member.png

      Comment


        #4
        Re: SQL Select Argument Passing Issue

        Hi Al:

        I had previously tried your suggestion below, and it failed as well.

        Although I can use the work around, I hope at some point it can be determined what I have done wrong or if this is a A5V8 software bug.

        Using <<% is a nice way to built SQL statements, amoung others.

        Originally posted by Al Buchholz View Post
        Gene

        instead of
        args.set("TestName","'5AM Partners%'")


        try taking off the single quotes....

        args.set("TestName","5AM Partners%")
        Eugene Saltz, QuickBooks Certified ProAdvisor, Microsoft Certified Systems Engineer
        Saltz Consulting LLC
        [email protected]
        www.saltzconsulting.com
        QuickBooks Sales & Support - Advanced Certified QuickBooks ProAdvisors - Enterprise Solution Providers

        Comment


          #5
          Re: SQL Select Argument Passing Issue

          Originally posted by ecsaltz View Post
          Hi Al:

          I had previously tried your suggestion below, and it failed as well.

          Although I can use the work around, I hope at some point it can be determined what I have done wrong or if this is a A5V8 software bug.

          Using <<% is a nice way to built SQL statements, amoung others.
          Is the work around the script that I sent?

          Please send more of your script. You've only shown part of it. You've not executed the SQL with the code that you've sent so far.

          BTW, I modified the action script generated code got it to fail with the single quotes and to work without the single quotes.... That's why I sent that suggestion to you.

          Something is missing here....
          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.
          "Make it as simple as possible, but not simpler."
          Albert Einstein

          http://www.iadn.com/images/media/iadn_member.png

          Comment


            #6
            Re: SQL Select Argument Passing Issue

            Originally posted by ecsaltz View Post
            I am using QODBC to select and also insert records in a QuickBooks company data file.

            Using XBasic, I can connect and retrieve what I need. For example, the following pertinent code excerpt works as expected:

            ......
            sqlStatement = <<%sql%
            SELECT CompanyName, BillAddressCity, BillAddressState, BillAddressPostalCode FROM Customer WHERE CompanyName LIKE '5AM Partners%'
            '%sql%
            .....

            Here, I am looking for a CompanyName that starts with 5AM Partners... from the Customer table. With the rest of the code not shown, it works fine.

            But, I would like to pass as an argument to the SQL the CompanyName to search by. So, this is what I think should work:

            dim args as sql::arguments
            args.set("TestName","'5AM Partners%'")
            sqlStatement = <<%sql%
            SELECT CompanyName, BillAddressCity, BillAddressState, BillAddressPostalCode FROM Customer WHERE CompanyName LIKE :TestName
            %sql%

            This doesn't work - it returns an error dialog box saying: An argument value was reference in the SQL query, but no argument list was provided.

            Would any one know the correct syntax for this?

            Thanks a bunch!

            UPDATE:

            The following code does work:

            temp1 = "'5AM Partners%'"
            sqlStatement = "SELECT CompanyName, BillAddressCity FROM Customer WHERE CompanyName LIKE " + temp1

            So, is it a problem with the <<%sql%.....%sql% being used with args.set(), perhaps at the end of the line?

            Curious minds want to know...

            Comment


              #7
              Re: SQL Select Argument Passing Issue

              Okay Al, here is the complete code. Note that this was based on an action script converted to XBasic.

              BTW, after "adjusting" to the XBasic syntax and the enormity of functions, methods and events, I am beginning to get a "warm, comfy" feeling with A5V8. I have had past experience in a number of development environments (Powerbuilder, VB, dBase, Clipper, FVP + VFE, etc.,) and the stock product is a pretty complete IDE.

              ====================================================

              'Execute a query on a SQL database
              'DIM a connection variable
              DIM cn as SQL::Connection
              dim flagResult as l
              flagResult = cn.open("::Name::OldTestQBalance")
              if flagResult = .f. then
              ui_msg_box("Error","Could not connect to database. Error reported was: " + crlf() + cn.CallResult.text)
              end
              end if

              'Specify if you are using Portable SQL syntax, or not
              cn.PortableSQLEnabled = .t.

              dim sqlStatement as c

              dim args as sql::arguments

              args.set("TestName","'5AM Partners%'")

              sqlStatement = <<%sql%
              SELECT CompanyName, BillAddressCity, BillAddressState, BillAddressPostalCode FROM Customer WHERE CompanyName LIKE :TestName
              %sql%

              'Execute the Query
              flagResult = cn.Execute(sqlStatement)
              if flagResult = .f. then
              ui_msg_box("Error",cn.CallResult.text)
              cn.close()
              end
              end if
              dim rs as sql::resultset
              rs = cn.ResultSet
              'The sql_resultset_preview() function opens a window showing a table with the results
              'of your query. Show a maximum of 1,000 rows of data
              'Note that the connection object is passed into the sql_resultset_preview() function so that the
              'function can immediately release the resultset, thereby releasing any locks on the database that some databases might
              'have applied.
              sql_resultset_preview(rs,1000,"Preview Query Results",cn)
              'Now, close the connection
              cn.close()



              Originally posted by Al Buchholz View Post
              Is the work around the script that I sent?

              Please send more of your script. You've only shown part of it. You've not executed the SQL with the code that you've sent so far.

              BTW, I modified the action script generated code got it to fail with the single quotes and to work without the single quotes.... That's why I sent that suggestion to you.

              Something is missing here....
              Eugene Saltz, QuickBooks Certified ProAdvisor, Microsoft Certified Systems Engineer
              Saltz Consulting LLC
              [email protected]
              www.saltzconsulting.com
              QuickBooks Sales & Support - Advanced Certified QuickBooks ProAdvisors - Enterprise Solution Providers

              Comment


                #8
                Re: SQL Select Argument Passing Issue

                The on-line help file covers the use of SQL functions such as 'execute' and it a good place to search for answers. This should be helpful.

                Comment


                  #9
                  Re: SQL Select Argument Passing Issue

                  Thanks Jerry. I had found this reference earlier and based a successful alternative solution on it.

                  But, I still would like to know why the original technique using <<%sql% to build the SQL string, and passing an args.set, as generated by the action script, failed. This might have something to do with QODBC, when I have a chance I will try it against another ODBC source.

                  Originally posted by JerryBrightbill View Post
                  The on-line help file covers the use of SQL functions such as 'execute' and it a good place to search for answers. This should be helpful.
                  Eugene Saltz, QuickBooks Certified ProAdvisor, Microsoft Certified Systems Engineer
                  Saltz Consulting LLC
                  [email protected]
                  www.saltzconsulting.com
                  QuickBooks Sales & Support - Advanced Certified QuickBooks ProAdvisors - Enterprise Solution Providers

                  Comment


                    #10
                    Re: SQL Select Argument Passing Issue

                    Not sure if this is the same issue but:

                    dim tem as c
                    tem = currentform.Controls.MO_TO_FIND
                    dim args as SQL::Arguments
                    args.add("ar1",tem)

                    The first thing I though of was that I HAD to use a variable, couldn't use the control. I also haven't been able to use a session variable directly in the argument definition; had to assign it to its own variable like above. I was able to assign discrete values without a variable.

                    The second thing I noticed is that you are using args.set... I use args.add. Any practical difference?

                    I am using AlphaDAO to access a SQL Server DB so perhaps there are differences there...

                    PS. the Help file and action scripting ARE NOT updated to reflect using AlphaDAO on the web. The script genie included ui_msg_box which won't work on the web. I had to learn this from a user on the forum as it is not mentioned in the help files.....

                    Erik

                    Comment

                    Working...
                    X