Microsoft Dynamics GP Developing for Dynamics GP
A blog dedicated to the Microsoft Dynamics GP Developer & Consultant community
 
Welcome to MSDN Blogs Sign in | Join | Help

Developing for Dynamics GP

by David Musgrave (Australia) and the Microsoft Dynamics GP Developer Support Team (USA)

News

  • Please use the Blog Feedback? - Contact Us link at the top of the page to email questions relating to the blog itself.

    If you wish to ask a technical question, please use the links below to ask on the Newsgroups. If you ask on the Newsgroups, others in the community can respond and the answers are available for everyone in the future.

    Please do not use comments on pages and posts to ask questions unrelated to the topic on that page or post.



    Dates of Interest:

    11-Jul-2008: Blog Created by David Musgrave.
    10-Oct-2008: First Post by Scott Stephenson.
    04-Nov-2008: First Post by Dave Dusek.
    11-Nov-2008: First Post by Beth Gardner.
    28-Nov-2008: First Post by Chris Roehrich.
    30-Dec-2008: First Post by Patrick Roth.
    24-Feb-2009: First Post by Greg Willson.
    22-Apr-2009: First Post by David Clauson.
    04-May-2009: First Post by Ryan Wigestrand.
    19-Jun-2009: First Post by Dawn Langlie.
    03-Jul-2009: First Post by Emily Halvorson.
    23-Sep-2009: Created Twitter account with blog feed.



    WorldMaps Statistics since
    24-Feb-2009:




    Click for WorldMaps Stumbler



    Translator Tool:




    Social Networking

    Follow David Musgrave and the blog on:

    David Musgrave on Twitter

    David Musgrave on LinkedIn


    Disclaimer

    This blog is provided "AS IS" with no warranties, and confers no rights.

    The links in this blog may lead to third-party Web sites. Microsoft provides third-party resources to help you find customer service and/or technical support resources. Information at these sites may change without notice. Microsoft is not responsible for the content at any third-party Web sites and does not guarantee the accuracy of third-party information.

Contents

Favourite Posts

Blog Links

Newsgroups Links

Resources Links

Microsoft Dynamics GP and Illegal Characters Part 1

David MeegoOver the years that I have worked with Microsoft Dynamics GP, there are been a few occasions where we have had issues with so called "illegal" characters.

While the use of these characters should work everywhere, there are times when the characters are not handled correctly by the system and so cause problems.  The characters in question are the quote or apostrophe characters; the single quote ('), ASCII 39; the double quote ("), ASCII 34; and the back quote (`) ASCII 96.


Boring Theory Stuff

Those of you who have a development background would know that when the character used to delimit a string field needs to be included in a string field, you would usually need to use some sort of special handling to prevent the string field being terminated prematurely.

Here are some examples to demonstrate what I mean:

Dexterity uses a double quote (") as a string terminator. So to display a string including a double quote, I need to either use two double quotes, use the QUOTE constant, or use the char() function with the ASCII value of 34.

warning "This is a "" character";
warning "This is a " + QUOTE + " character";
warning "This is a " + char(34) + " character";

Visual Basic for Applications (VBA) also uses a double quote (") as a string terminator. So to display a string including a double quote, I need to either use two double quotes or use the chr() function with the ASCII value of 34.

msgbox "This is a "" character"
msgbox "This is a " + Chr(34) + " character"

Transact SQL uses a single quote (') as a string terminator. So to display a string including a single quote, I need to use two single quotes.

print 'This is a '' character'

This special handling for the string terminator character is usually handled during the development process and so usually does not cause any issues. 

Also, the development environments usually will understand the special requirements for the string terminator and handle it appropriately. 

For example: when Dexterity sends data to SQL Server it will automatically handle the conversion of a single quote in a string field to two single quotes to avoid early termination of the field.


The Real World 

So when can these characters cause problems....

The problem occurs when code is built on the fly and the string terminator is not handled correctly.  In Dexterity, we have the ability to create pass through sanScript Dexterity code that we can run with the execute() function.  We also have the ability to pass code to SQL Server as part of a where clause or as pass through Transact-SQL code.

The following Knowledge Base (KB) article explains how to use the SQL_FormatStrings() function to ensure that any single quote characters in the data are handled correctly:

How to write "Passthrough" SQL statements and "Range Where" clauses in Microsoft Great Plains Dexterity (KB 910129) Secure Link

If a Dexterity developer writes code where the data from a string field is passed to SQL Server without using the SQL_FormatStrings() function, then the inclusion of a single quote into the data field can cause the code to fail.  If this situation happens, it should be logged as a support case with the developer so they can find and fix the offending code.

Another situation that can cause issues is when a stored procedure in SQL Server uses dynamically built code to pass through SQL code using the exec command.  This code also needs to handle the single quote correctly. A SQL User Defined Function (UDF) could be written to perform the same function as the SQL_FormatStrings() Dexterity function.

More information to come in the next post..... Microsoft Dynamics GP and Illegal Characters Part 2

 

Also have a look at this related KB article for handling of dates and times.

How to pass dates and times to SQL Server from Dexterity in Microsoft Dynamics GP (KB 929786) Secure Link

Hope this information is useful.

David

Posted: Monday, June 22, 2009 9:00 AM by David Musgrave
Leave a Comment

(required) 

(required) 

(optional)

(required) 

  
Enter Code Here: Required

Comment Notification

If you would like to receive an email when updates are made to this post, please register here

Subscribe to this post's comments using RSS

Page view tracker