Hello All, When passing a connection object between DLL's it appears that myODBC driver is not able to create Editable RecordSets objects from it. However, I can create Static RecordSet objects. A work around that I have found is to have the 2nd DLL open a new connection object.
Code samples follow: Any suggestions? ENetArch Code samples: =========================================================== EXE - 1 Dim objStore As Store_mySQL Const szODBC = "UID=sa;PWD=sa;DSN=mySQL;" Sub Main() Set objStore = New Store_mySQL Dim cn As Object Set cn = CreateObject("adodb.connection") cn.open (szODBC) Set objStore.init = cn objStore.Test End Sub =========================================================== Table Defination CREATE TABLE test ( ID INTEGER AUTO_INCREMENT, PRIMARY KEY (ID), szName VARCHAR (30) ) =========================================================== DLL - Store_mySQL Private cn As Connection Private Sub Class_Initialize() Set cn = Nothing End Sub Public Property Set init(ByVal objCn As Connection) Set cn = objCn ' Work Around ' Set cn = CreateObject("adodb.connection") ' cn.Open objCn End Property Public Function test() Const cSQLTable = "test" Dim szSQL As String Dim rs As Object szSQL = _ " SELECT * " & _ " FROM " & cSQLTable & _ " ORDER BY ID " ' rs = cn.execute (szSQL) ' returns a static record set OK, without workaround. Set rs = CreateObject("ADODB.RecordSet") rs.CursorLocation = 3 ' adUseClient rs.CursorType = 1 ' adOpenKeyset rs.LockType = 3 ' adLockOptimistic rs.Source = szSQL Set rs.ActiveConnection = cn ' Fails here: error 3709, or 3001 rs.Open rs.AddNew rs("szName") = "NavisStar International, Inc." rs.Update Debug.Print rs("ID") End Function =========================================================== ' Keywords: ' myODBC, Visual Basic, VB, ADODB.RECORDSET ' ADODB.CONNECTION, ADO ' ERROR 3001 : INVALID CONNECTION ' The application is using arguments that are of the wrong type, ' are out of acceptable range, or are in conflict with one another. ' ERROR 3709 : INVALID ARGUMENT ' The application requested an operation on an object with a ' reference to a closed or invalid Connection object. ' Environment: ' WkStn - Windows 2000 WkStn, 256 meg, AMD K6-2 500 mhz, build 2195, SP1 ' MDAC 2.7 ' myODBC 3.51 - WinX --------------------------------------------------------------------- Before posting, please check: http://www.mysql.com/manual.php (the manual) http://lists.mysql.com/ (the list archive) To request this thread, e-mail <[EMAIL PROTECTED]> To unsubscribe, e-mail <[EMAIL PROTECTED]> Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php