WinBatch Tech Support Home

Database Search

If you can't find the information using the categories below, post a question over in our WinBatch Tech Support Forum.

TechHome

ODBC
plus

Can't find the information you are looking for here? Then leave a message over on our WinBatch Tech Support Forum.

521 Attribute string too long

 Keywords:  

Question:

Fairly simple process, got some code from here to compact some access databases. the relevant bit is here:
request=2;ODBC_CONFIG_DSN
driver="Microsoft Access Driver (*.mdb)";
attrs = 'COMPACT_DB="' : databasename : '" "' : databasename : '" General'
displayflag=@FALSE
ret=qConfigData(request, driver, attrs, displayflag)
Message("qConfigData - Created DSN",ret)
qFreeConnect(hdbc)
qFreeEnv(henv)
My problem is the attrs gets too large, presumably because the network path is 153 characters (which is repeated). Any thoughts of getting around this?

Answer:

Looks like the ODBC Extender function qCondifData has a limit of 256 characters for the attributes parameter. Not quite sure why that is.

Here is a workaround to the limitation in the qConfigData attributes parameter:


; Types of operations that can be performed
ODBC_ADD_DSN             =1  ; Add data source
ODBC_CONFIG_DSN          =2  ; Configure (edit) data source
ODBC_REMOVE_DSN          =3  ; Remove data source
ODBC_ADD_SYS_DSN         =4  ; add a system DSN
ODBC_CONFIG_SYS_DSN      =5  ; Configure a system DSN
ODBC_REMOVE_SYS_DSN      =6  ; remove a system DSN

; Return Codes
SQL_FALSE = 0
SQL_TRUE  = 1

databasename = 'D:\temp\Data\zipcodes.mdb'
strDriver = 'Microsoft Access Driver (*.mdb)'
strAttr = 'COMPACT_DB="' : databasename : '" "' : databasename : '" General'

obdcdll = DirWindows(1):"ODBCCP32.DLL"
ret = DllCall( obdcdll, long:"SQLConfigDataSource", long:0, long:ODBC_CONFIG_DSN, lpstr:strDriver, lpstr:strAttr )
If ret <> SQL_TRUE
   Message( "SQL FAILED", ret )
EndIf

Pause('Compact','Successful')
Exit

Article ID:   W17583
Filename:   521 Attribute string too long.txt
File Created: 2012:11:26:09:50:54
Last Updated: 2012:11:26:09:50:54