Syntax question

Kenneth Brody kenbrody at spamcop.net
Wed Jun 5 14:38:05 PDT 2013


On 6/5/2013 4:33 PM, Richard Hane wrote:
> fpODBC 1.0.15
>
> DSN = fp-sqlserver
>
> Which one of the following two lines is correct?  Both pass syntax check
> and will run when tested.
>
> Connection = new ODBC_CONNECTION("fp-sqlserver")
>
> or
>
> Connection = new ODBC_CONNECTION("fp-sqlserver ; ")
>
> The question has to do with the semi colon at the end of the statement.
>
> I am still trying to resolve why the connection sometimes fails.  Then if
> you immediately run it again it works correctly.

filePro doesn't do any "syntax check" on the value that you pass to NEW 
ODBC_CONNECTION(), as the data can contain driver-specific information. 
Both of the above statements are valid filePro syntax, regardless of whether 
the DSN is valid or not.  The value you give is passed as-is to the ODBC 
library.

Note that all of my tests use something like "DSN=fp-sqlserver;" rather than 
just the raw "fp-sqlserver".  However, if your value works most of the time, 
then it must be valid to use that syntax.

For more information on the DSN format, check:

     http://msdn.microsoft.com/en-US/library/c689y99f(v=vs.100).aspx

Now, as to why it sometimes fails...

Obviously, if you pass the same DSN, and it works most of the time, but 
fails sometimes (and works if you try it a few seconds later), then it's 
probably either a network or a timing issue.

Have you considered checking the @ODBCERROR[] system array to see what it 
says failed?  That might point you to the root cause.

Also, if you know that it will work if you wait a few seconds and try it 
again, consider doing that in your processing.  That is, if NEW 
ODBC_CONNECTION() fails, use SLEEP to wait a few seconds, and try creating 
the connection again.  (If this is interactive, perhaps use a SHOW POPUP to 
display a message to the user, to let them know what's going on.)  You may 
want to put a counter in there, to limit the number of retries, in case it's 
not a transient error that time.

-- 
Kenneth Brody


More information about the Filepro-list mailing list