Re: Matt - MSADO15.ew
- Posted by Matt Lewis <matthewwalkerlewis at yahoo.com> Oct 27, 2004
- 973 views
Jonas Temple wrote: > > Thanks for the reply! What is ConnectionEventsVt used for? I didn't have > that in my MSADO15.ew created by tbrowse. I believe that I discovered this on the web--after getting the could not find implemented interface. I believe that it's the straight vtable interface, as opposed to the dispinterface. Not certain, though. > When I ran my test program I got the following: > > IUnknown::QueryInterface(80004002) > Could not find implemented interface: 00000402-0000-0010-8000-00AA006D2EA4 > > IUnknown::QueryInterface > Found implemented interface: 00000400-0000-0010-8000-00AA006D2EA4 > > 80020009: Exception occurred. > Exception Source: ADODB.Connection > Exception Description: Operation has been cancelled by the user. > 80020009: Exception occurred. > Exception Source: ADODB.Connection > Exception Description: Operation is not allowed when the object is closed. > > The problem is I don't know how I cancelled the operation. Do you have > a working example of connection to a data source with ADO? > It seems to work if you set up a DSN and then use that as your connect string. Here's my example:
without warning include eucom.ew include msado15.ew atom ado_connect, void, conn_str com_err_out(1) ado_connect = create_com_object(Connection_clsid_ix) -- Event functions for ConnectionEvents with trace procedure ConnectionEvents_InfoMessage_proc( atom this, atom pError, atom adStatus, atom pConnection ) puts(1,"InfoMessage\n") end procedure com_event_routine( ado_connect, ConnectionEvents_InfoMessage, routine_id("ConnectionEvents_InfoMessage_proc" )) procedure ConnectionEvents_BeginTransComplete_proc( atom this, atom TransactionLevel, atom pError, atom adStatus, atom pConnection ) puts(1,"BeginTransComplete\n") end procedure com_event_routine( ado_connect, ConnectionEvents_BeginTransComplete, routine_id("ConnectionEvents_BeginTransComplete_proc" )) procedure ConnectionEvents_CommitTransComplete_proc( atom this, atom pError, atom adStatus, atom pConnection ) puts(1,"CommitTransComplete\n") end procedure com_event_routine( ado_connect, ConnectionEvents_CommitTransComplete, routine_id("ConnectionEvents_CommitTransComplete_proc" )) procedure ConnectionEvents_RollbackTransComplete_proc( atom this, atom pError, atom adStatus, atom pConnection ) puts(1,"RollbackTransComplete\n") end procedure com_event_routine( ado_connect, ConnectionEvents_RollbackTransComplete, routine_id("ConnectionEvents_RollbackTransComplete_proc" )) procedure ConnectionEvents_WillExecute_proc( atom this, atom Source, atom CursorType, atom LockType, atom Options, atom adStatus, atom pCommand, atom pRecordset, atom pConnection ) puts(1,"WillExecute\n") end procedure com_event_routine( ado_connect, ConnectionEvents_WillExecute, routine_id("ConnectionEvents_WillExecute_proc" )) procedure ConnectionEvents_ExecuteComplete_proc( atom this, atom RecordsAffected, atom pError, atom adStatus, atom pCommand, atom pRecordset, atom pConnection ) puts(1,"ExecuteComplete\n") end procedure com_event_routine( ado_connect, ConnectionEvents_WillConnect, routine_id("ConnectionEvents_ExecuteComplete_proc" )) procedure ConnectionEvents_WillConnect_proc( atom this, atom ConnectionString, atom UserID, atom Password, atom Options, atom adStatus, atom pConnection ) puts(1,"WillConnect\n") end procedure com_event_routine( ado_connect, ConnectionEvents_WillConnect, routine_id("ConnectionEvents_WillConnect_proc" )) procedure ConnectionEvents_ConnectComplete_proc( atom this, atom pError, atom adStatus, atom pConnection ) puts(1,"ConnectComplete\n") end procedure com_event_routine( ado_connect, ConnectionEvents_ConnectComplete, routine_id("ConnectionEvents_ConnectComplete_proc" )) procedure ConnectionEvents_Disconnect_proc( atom this, atom adStatus, atom pConnection ) puts(1,"Disconnect\n") end procedure com_event_routine( ado_connect, ConnectionEvents_Disconnect, routine_id("ConnectionEvents_Disconnect_proc" )) conn_str = alloc_bstr( "DSN=weapons;" ) void = invoke( ado_connect, {Connection_p_ConnectionString}, {conn_str}, {VT_BSTR}, DISPATCH_PROPERTYPUT ) void = invoke(ado_connect, {"Open"},{},{},DISPATCH_METHOD) ? invoke(ado_connect, {"State"}, {},{}, DISPATCH_PROPERTYGET ) void = invoke(ado_connect, {Connection_m_Close},{},{},DISPATCH_METHOD) free_bstr(conn_str) abort(wait_key())
To set up a dsn, go to (Win2K/XP): Control Panel -> Administrative Tools -> Data Sources (ODBC) In Win9X, I believe that the ODBC option is right there in Control Panel. Matt Lewis