I have a Microsoft Access database on Microsoft Windows that I want to
process using Pharo. ConfigurationOfODBC looked promising so followed instructions at http://www.pharocasts.com/2010/12/access-database-through-odbc.html, though using a blank MDB file rather than SQLLite, and 'TestMDB' as the ODBC DSN, I executed... --8<--- Gofer new squeaksource: 'ODBC'; package: 'ConfigurationOfODBC'; load. (Smalltalk at: #ConfigurationOfODBC) load. connection := ODBCConnection dsn: 'TestMDB' user: '' password: ''. connection execute: 'CREATE TABLE user(name varchar(10), age smallint)'. connection execute: 'INSERT INTO user VALUES(''Old Bob'', 100)'. contents := (connection query: 'select * from user;') execute: ''. contents asTable inspect. connection close. --8<--- which failed on Pharo 1.3 but worked on Pharo 1.2.1. To debug this I compared each by single stepping 1.3 & 1.2.1 side-by-side. I executed... connection := ODBCConnection dsn: 'TestMDB' user: '' password: ''. which seemed to worked the same on both platforms up to the inserted 'self halt' shown here... --8<--- ODBCConnection>>connect "Connect to the database" self registerForFinalization. hEnv := self sqlAllocEnv. false ifTrue: [ self sqlSetEnvAttr: 200 value: 2 "SQL_ATTR_ODBC_VERSION" ]. self halt. hdbc := self sqlAllocConnect: hEnv. --8<--- ODBCConnection>>sqlAllocConnect: envHandle | h | h := SQLHDBC new. self checkSQLReturn: (ODBCLibrary default sqlAllocConnectEnvironment: hEnv connection: h ). ^h --8<--- ODBCLibrary(Object)>>sqlAllocConnectEnvironment: environmentHandle connection: connectionHandle "SQLRETURN SQLAllocConnect( SQLHENV EnvironmentHandle, SQLHDBC *ConnectionHandle);" <cdecl: short 'SQLAllocConnect' (SQLHENV SQLHDBC*)> ^ self externalCallFailed --8<--- ODBCConnection>>checkSQLReturn: sqlReturn "private - check the sqlReturn and generates an exception if corresponds" self checkSQLReturn: sqlReturn environment: hEnv connection: hdbc statement: nil --8<--- If you've followed the call chain down to here, then the result is... In Pharo 1.2.1 (WinXP & Win7) primitive SQLAllocConnect primitive succeeds, with sqlReturn=0 In Pharo 1.3 (WinXP & Win7) primitive SQLAllocConnect primitive succeeds, with sqlReturn=-2 I cannot find what -2 may mean on any of the Microsoft ODBC API pages, nor a few header files I checked (though I may have missed some header file) ================= To investigate further, I thought to try running the bypassed code... --8<--- ODBCConnection>>connect "Connect to the database" self registerForFinalization. hEnv := self sqlAllocEnv. self halt. true ifTrue: [ self sqlSetEnvAttr: 200 value: 2 "SQL_ATTR_ODBC_VERSION" ]. --8<--- sqlSetEnvAttr: attr value: value self checkSQLReturn: (ODBCLibrary default sqlSetEnvAttr: hEnv attr: attr value: value length: 0 ) --8<--- sqlSetEnvAttrPtr: hEnv attr: attr value: value length: length "SQLRETURN SQLSetEnvAttr( SQLHENV EnvironmentHandle, SQLINTEGER Attribute, SQLPOINTER ValuePtr, SQLINTEGER StringLength);" <cdecl: short 'SQLSetEnvAttr' (SQLHENV long void* long)> ^ self externalCallFailed --8<--- For both 1.2.1 and 1.3 'self externalCallFailed' is executed for 1.2.1 errCode=12 'No module to load address from' for 1.3 errCode=13 'Unable to find function address' --8<--- Pointers anyone? btw, In parallel I am also trying out DBXTalk. |
did you check the plugins?
are they the same? Stef On Nov 24, 2011, at 3:31 PM, Ben Coman wrote: > I have a Microsoft Access database on Microsoft Windows that I want to process using Pharo. ConfigurationOfODBC looked promising so followed instructions at http://www.pharocasts.com/2010/12/access-database-through-odbc.html, > though using a blank MDB file rather than SQLLite, and 'TestMDB' as the ODBC DSN, I executed... > --8<--- > Gofer new > squeaksource: 'ODBC'; > package: 'ConfigurationOfODBC'; load. > (Smalltalk at: #ConfigurationOfODBC) load. > > connection := ODBCConnection dsn: 'TestMDB' user: '' password: ''. > connection execute: 'CREATE TABLE user(name varchar(10), age smallint)'. > connection execute: 'INSERT INTO user VALUES(''Old Bob'', 100)'. > contents := (connection query: 'select * from user;') execute: ''. > contents asTable inspect. > connection close. > --8<--- > which failed on Pharo 1.3 but worked on Pharo 1.2.1. To debug this I compared each by single stepping 1.3 & 1.2.1 side-by-side. > I executed... connection := ODBCConnection dsn: 'TestMDB' user: '' password: ''. > which seemed to worked the same on both platforms up to the inserted 'self halt' shown here... > --8<--- > ODBCConnection>>connect > "Connect to the database" > self registerForFinalization. > hEnv := self sqlAllocEnv. > false ifTrue: > [ self > sqlSetEnvAttr: 200 > value: 2 "SQL_ATTR_ODBC_VERSION" ]. > self halt. > hdbc := self sqlAllocConnect: hEnv. > --8<--- > ODBCConnection>>sqlAllocConnect: envHandle > | h | > h := SQLHDBC new. > self checkSQLReturn: (ODBCLibrary default > sqlAllocConnectEnvironment: hEnv connection: h > ). > ^h > --8<--- > ODBCLibrary(Object)>>sqlAllocConnectEnvironment: environmentHandle connection: connectionHandle > "SQLRETURN > SQLAllocConnect( > SQLHENV EnvironmentHandle, > SQLHDBC *ConnectionHandle);" > <cdecl: short 'SQLAllocConnect' (SQLHENV SQLHDBC*)> > ^ self externalCallFailed > --8<--- > ODBCConnection>>checkSQLReturn: sqlReturn > "private - check the sqlReturn and generates an exception if corresponds" > self > checkSQLReturn: sqlReturn > environment: hEnv > connection: hdbc > statement: nil > --8<--- > If you've followed the call chain down to here, then the result is... > In Pharo 1.2.1 (WinXP & Win7) primitive SQLAllocConnect primitive succeeds, with sqlReturn=0 > In Pharo 1.3 (WinXP & Win7) primitive SQLAllocConnect primitive succeeds, with sqlReturn=-2 > I cannot find what -2 may mean on any of the Microsoft ODBC API pages, nor a few header files I checked (though I may have missed some header file) > ================= > To investigate further, I thought to try running the bypassed code... > --8<--- > ODBCConnection>>connect > "Connect to the database" > self registerForFinalization. > hEnv := self sqlAllocEnv. > self halt. > true ifTrue: > [ self > sqlSetEnvAttr: 200 > value: 2 "SQL_ATTR_ODBC_VERSION" ]. > --8<--- > sqlSetEnvAttr: attr value: value > self checkSQLReturn: (ODBCLibrary default > sqlSetEnvAttr: hEnv attr: attr value: value length: 0 > ) > --8<--- > sqlSetEnvAttrPtr: hEnv attr: attr value: value length: length > "SQLRETURN SQLSetEnvAttr( > SQLHENV EnvironmentHandle, > SQLINTEGER Attribute, > SQLPOINTER ValuePtr, > SQLINTEGER StringLength);" > <cdecl: short 'SQLSetEnvAttr' (SQLHENV long void* long)> > ^ self externalCallFailed > --8<--- > For both 1.2.1 and 1.3 'self externalCallFailed' is executed > for 1.2.1 errCode=12 'No module to load address from' > for 1.3 errCode=13 'Unable to find function address' > --8<--- > Pointers anyone? > btw, In parallel I am also trying out DBXTalk. > |
Hi Bon. Are you using exactly the same VM for both, 1.3 and 1.2.1?
from what I can see it looks like if FFI doesn't find the odbc library. cheers On Thu, Nov 24, 2011 at 4:57 PM, Stéphane Ducasse <[hidden email]> wrote: did you check the plugins? -- Mariano http://marianopeck.wordpress.com |
Mariano Martinez Peck wrote:
Hi Ben. Are you using exactly the same VM for both, 1.3 and 1.2.1? I am using the default downloads of both version 1.2.1 and 1.3, both downloaded and installed two days ago. How do I work out myself which VM version is being used. My common practice on windows is inconclusive... Pharo-1.2.1-OneClick > pharo.exe > right-click > Properties > Details >> version 4.1.1.0 Pharo-1.3-13315-OneClick > pharo.exe > right-click > Properties > Details >> there are no details, its all blank. Pharo-1.2.1-OneClick > SqueakFFIPrims.dll > right-click > Properties > Details >> there are no details, its all blank. Pharo-1.3-13315-OneClick > SqueakFFIPrims.dll > right-click > Properties > Details >> there are no details, its all blank. Is there some FFI debug logging I can turn on for ? Looking around I found the command 'SmalltalkImage current listLoadedModules ' which gives results: Pharo-1.2.1 #( 'ZipPlugin 3 April 2010 (i)' / 'SocketPlugin 3 April 2010 (i)' 'odbc32' 'SurfacePlugin Mar 3 2011 (i)' 'SqueakFFIPrims 3 April 2010 (e)' 'Matrix2x3Plugin 3 April 2010 (i)' 'FloatArrayPlugin 3 April 2010 (i)' 'LargeIntegers v1.5 3 April 2010 (i)' 'LocalePlugin 3 April 2010 (i)' 'B2DPlugin 3 April 2010 (i)' 'BitBltPlugin 3 April 2010 (i)' 'SecurityPlugin 3 April 2010 (i)' 'FilePlugin 3 April 2010 (i)' 'MiscPrimitivePlugin 3 April 2010 (i)' ) Pharo-1.3-13355 #( 'Matrix2x3Plugin VMMaker-oscog-IgorStasenko.123 (i)' 'FloatArrayPlugin VMMaker-oscog-IgorStasenko.123 (i)' 'odbc32' 'SurfacePlugin Aug 31 2011 (i)' 'SqueakFFIPrims VMMaker-oscog-IgorStasenko.123 (e)' 'LocalePlugin VMMaker-oscog-IgorStasenko.123 (i)' 'B2DPlugin VMMaker-oscog-IgorStasenko.123 (i)' 'BitBltPlugin VMMaker-oscog-IgorStasenko.123 (i)' 'LargeIntegers v1.5 VMMaker-oscog-IgorStasenko.123 (i)' 'SecurityPlugin VMMaker-oscog-IgorStasenko.123 (i)' 'FilePlugin VMMaker-oscog-IgorStasenko.123 (i)' 'MiscPrimitivePlugin VMMaker-oscog-IgorStasenko.123 (i)' ) I thought I'd try to have a look at the VM source, so I followed instructions at http://book.pharo-project.org/book/Virtual-Machine/Building/BuildVMOnWindows/BuildCogVMOnWindows/ but got the following result $ svn co http://www.squeakvm.org/svn/squeak/branches/Cog/platforms svn: E175002: Unable to connect to a repository at URL 'http://www.squeakvm.org/svn/squeak/branches/Cog/platforms' svn: E175002: OPTIONS of 'http://www.squeakvm.org/svn/squeak/branches/Cog/platforms': could not connect to server (http://www.squeakvm.org) I'll try some more tomorrow |
Hi, I'm having the same issue while trying to use ODBC with Pharo's OnClick image 1.3. Did you find anything about the issue here? Regards, Fadi |
Fadi Mansour wrote:
> Hi, > > I'm having the same issue while trying to use ODBC with Pharo's OnClick > image 1.3. > > Did you find anything about the issue here? > > Regards, > > Fadi > > > > > mine site. I've only just got back today to start having a look at it again. |
Hi. Just as a test, would you like to test the attached VM? change xxx with zip.
Just make sure odbc libraries are findable by Windows. Cheers On Sun, Dec 11, 2011 at 6:45 AM, Ben Coman <[hidden email]> wrote:
-- Mariano http://marianopeck.wordpress.com |
Free forum by Nabble | Edit this page |