Any PB & ADO gurus?
- Posted by ken mortenson <kenneth_john at yaho?.com> May 24, 2008
- 636 views
You were so helpful for me before (thx Jason) I was hoping someone might get me unstuck again so I can get to the fun part of writing code. A little background. I bought PowerBASIC years ago because I wanted a good compiler. But I find PB to be both ugly and incomplete. While I've always liked the core C language, I find it gets dirty quickly. Euphoria is very clean and well named. It is euphoric writing code with such a flexible data type and it isn't cluttered with a lot of junk. Anyway, to my issue; Here's the PB (double ugly IMHO) code... FUNCTION dbOpen ALIAS "dbOpen" (sPath AS ASCIIZ) EXPORT AS LONG DIM v1 AS VARIANT ON ERROR GOTO ErrorTrap LET m_db = NEW DISPATCH IN "ADODB.Connection.2.7" LET m_rs = NEW DISPATCH IN "ADODB.Recordset.2.7" MSGBOX "CommandTimeout start" 'debug code v1 = 120 OBJECT LET m_db.CommandTimeout = v1 MSGBOX "CommandTimeout done" 'debug code v1 = 3 '%ado_Use_Client OBJECT LET m_db.CursorLocation = v1 v1 = "Provider=Microsoft.Jet.OLEDB.4.0; " _ & "Data Source=" & sPath & "; " _ & "User ID=ADMIN; " _ & "Password=;" OBJECT LET m_db.ConnectionString = v1 OBJECT CALL m_db.Open dbOpen = 1 'success EXIT FUNCTION ErrorTrap: dbOpen = 0 'failure LET m_db = NOTHING END FUNCTION ----------------------------------------------------- When I originally wrote this the param sPath was AS STRING, but Euphoria's allocate_string produces the PB type ASCIIZ so I changed that. This code works fine called from PB, but when called from Euphoria it fails on the line... OBJECT LET m_db.CommandTimeout = v1 I added the two messageboxes to bracket the problem. Called from Euphoria it never gets to the second messagebox. I'm baffled since disregarding the ugly syntax the line is pretty straight forward. Any ideas? Alternately, does anyone have another way of using ADO recordset from Euphoria? It would be nice if I could access any SQL db with just a new connection string as I can with this code. Why not use an EDB (anticipating your question) db? A number of reasons, basically because I know how to do safe multiuser calls to a SQL db, but don't see how that would work with an EDB. I'd be interested in that question as well. Hey, I'm interested in lots of things...