DBConnection<<open connection string size limit...

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

DBConnection<<open connection string size limit...

Christopher J. Demers
I was using DBConnection<<open to allow me to use an MS Access DSN with no
file name so I could browse for the database.  After I selected a database
in a fairly long path I got an error about access pas the end of the sting.
I saw that the connSz was being declared as a 256 byte string, but that the
actual connection string being returned was longer, lenConnSz indicated the
length.  As a quick workaround I just increased the initial size of connSz
to 500, and that let me open the file I needed to.

I wonder if this method should be enhanced to remove, or increase this
limitation?

Chris


Reply | Threaded
Open this post in threaded view
|

Re: DBConnection<<open connection string size limit...

Blair McGlashan-2
Chris you wrote in message
news:bf4p0s$avdma$[hidden email]...
> I was using DBConnection<<open to allow me to use an MS Access DSN with no
> file name so I could browse for the database.  After I selected a database
> in a fairly long path I got an error about access pas the end of the
sting.
> I saw that the connSz was being declared as a 256 byte string, but that
the
> actual connection string being returned was longer, lenConnSz indicated
the
> length.  As a quick workaround I just increased the initial size of connSz
> to 500, and that let me open the file I needed to.
>
> I wonder if this method should be enhanced to remove, or increase this
> limitation?

Thanks, recorded as #1306. Proposed fix below.

Regards

Blair

-------------------------
!DBConnection methodsFor!

open
 "Open the receiver after prompting for the connection details, but only
 if not already connected."

 | connSz lenConnSz |
 handle isNull ifFalse: [^self].

 [| ret |
 "#1306: From MSDN, 'Applications should allocate at least 1,024 bytes for
[the connection string] buffer'"
 connSz := String newFixed: 2048.
 lenConnSz := SWORD new.
 ret := ODBCLibrary default
    sqlDriverConnect: self getHandle
    windowHandle: UserLibrary default getActiveWindow
    inConnectionString: self connectString
    stringLength1: SQL_NTS
    outConnectionString: connSz
    bufferLength: connSz size
    stringLength2Ptr: lenConnSz
    driverCompletion: (self useDriverCompletion
      ifTrue: [SQL_DRIVER_COMPLETE]
      ifFalse: [SQL_DRIVER_NOPROMPT]).
 self dbCheckException: ret]
   ifCurtailed: [self free].
 self connectString: (connSz copyFrom: 1 to: (lenConnSz value min: connSz
size))! !
!DBConnection categoriesFor: #open!operations!public! !