[AccessD] Jet version sql error Try 2

Doug Murphy dw-murphy at cox.net
Tue Sep 11 16:40:51 CDT 2007


Hi Max,

When you use some APIs they ask for a variable to be dimensioned to be
passed into the api and into which the result is returned.  If you look at
the string that is returned there will be an asci 0 at the end. This is the
null I was refering to since that is what the asci table calls it.

Doug

-----Original Message-----
From: accessd-bounces at databaseadvisors.com
[mailto:accessd-bounces at databaseadvisors.com] On Behalf Of Gmail
Sent: Tuesday, September 11, 2007 2:31 PM
To: 'Access Developers discussion and problem solving'
Subject: Re: [AccessD] Jet version sql error Try 2

Hmmm,

I *think* it was returning a null, not a null terminated string.  How do you
do you trim a null "I trim one so there was an extra" ?  I do not know of
anyway to add a null to anything.

>Concatenation does not work with null terminated strings so my sql 
>string
didn't have the last semicolon and threw an error.
A null concatenated to anything returns a null.


Max



-----Original Message-----
From: accessd-bounces at databaseadvisors.com
[mailto:accessd-bounces at databaseadvisors.com] On Behalf Of Doug Murphy
Sent: Tuesday, September 11, 2007 10:06 PM
To: 'Access Developers discussion and problem solving'
Subject: Re: [AccessD] Jet version sql error Try 2

I finally figured out what the problem was. I use the GetLocalInfo API to
get the users computer country settings.  This API is supposed to give a
string length which you then use to dimension a variable into which the api
returns the country setting as a null terminated string that designates the
country, e.g., "United States" for the US.  This works as it is supposed to
for the later versions of Windows. For some reason when I test our runtime
on a Windows 98 SE computer the returned buffer length has one extra space
so I was getting the Country designation with 2 null characters on the end.
I trim one so there was an extra. 

The sql string was just a symptom of this problem. Concatenation does not
work with null terminated strings so my sql string didn't have the last
semicolon and threw an error.

When the country setting string is not null terminated all is well. 

-----Original Message-----
From: accessd-bounces at databaseadvisors.com
[mailto:accessd-bounces at databaseadvisors.com] On Behalf Of Gustav Brock
Sent: Tuesday, September 11, 2007 10:26 AM
To: accessd at databaseadvisors.com
Subject: Re: [AccessD] Jet version sql error Try 2

Hi Doug

This may be one of those situations where you just code it differently to
skip further debugging.
You could apply a filter to the recordset:

  sSQL = "Select * From tblUserFormat"
  Set db = CurrentDb
  Set rs = db.OpenRecordset(sSQL, dbOpenDynaset)
  rs.Filter = "fldCountry = '" & sCountrySettings & "'"
  Set rs = rs.OpenRecordset

/gustav


>>> dw-murphy at cox.net 11-09-2007 19:04 >>>
Hi Gustav,

This is a runtime that I install from a test CD.  It runs correctly on
operating systems other than win 98 SE.  I know the table is populated since
I put the values in and that the recordset returns values, when it runs
correctly.

As I responded to Max on his post I suspect this is something to do with the
version of jet used on Windows 98 and later versions of windows.  My
installer checks the windows version and loads the apprpropriate version of
Jet 4 SP8.  I just can't figure out why this simple string would be
interpreted differently.

Doug 

-----Original Message-----
From: accessd-bounces at databaseadvisors.com
[mailto:accessd-bounces at databaseadvisors.com] On Behalf Of Gustav Brock
Sent: Tuesday, September 11, 2007 6:24 AM
To: accessd at databaseadvisors.com
Subject: Re: [AccessD] Jet version sql error Try 2

Hi Doug

Strange, except that sSQL is never Null and dbOpenDynaset is the default
method for attached tables.
Try with another table/database to check if the table should be corrupt.

/gustav

>>> dw-murphy at cox.net 11-09-2007 06:13 >>>
 
OK I'll try again with a simpler (?) question.

Any one see a reason why the following sql string generates an error when
used to open a recordset?

"Select * From tblUserFormat Where fldCountry = 'United States';"

Generates an error 3075 when run in the following line:

"Set rs = db.OpenRecordset(sSQL, dbOpenDynaset)"

The error message that gives the error number 3075 indicates that there is
some problem with fldCountry = 'United States'

I have modified the code slightly from my first post to use a dynaset type
recordset and added the semicolon at the end of the query string.  Same
error is generated with the updated code.  The complete procedure up to this
point is as follows.

Public Sub GetCountrySettings()
Dim rs As DAO.Recordset
Dim db As DAO.Database
Dim sSQL As String
Dim sCountrySettings As String
Dim fld As Field
Dim LCID As Long

  LCID = 0  'GetSystemDefaultLCID()

   On Error GoTo GetCountrySettings_Error

      sCountrySettings = GetUserLocaleInfo(LCID, LOCALE_SCOUNTRY)
      tFM.sCountry = sCountrySettings
      
      If Not IsNull(sSQL) Then
            sSQL = "Select * From tblUserFormat Where fldCountry = '" &
sCountrySettings & "';"
            Set db = CurrentDb
            Set rs = db.OpenRecordset(sSQL, dbOpenDynaset)
            rs.MoveFirst

-- 



--
AccessD mailing list
AccessD at databaseadvisors.com
http://databaseadvisors.com/mailman/listinfo/accessd
Website: http://www.databaseadvisors.com

--
AccessD mailing list
AccessD at databaseadvisors.com
http://databaseadvisors.com/mailman/listinfo/accessd
Website: http://www.databaseadvisors.com

--
AccessD mailing list
AccessD at databaseadvisors.com
http://databaseadvisors.com/mailman/listinfo/accessd
Website: http://www.databaseadvisors.com




More information about the AccessD mailing list