Function RunQuery2(sSQL As String, Optional ds) As Variant
', Optional ADO As ADODB.Connection, Optional datasource 'Dim conADO As New ADODB.Connection Dim rs As New ADODB.Recordset Dim i As Integer ' Open the Connection. 'If IsMissing(datasource) Then ' 'End If 'End If If gADO Is Nothing Then 'gADO.Open "Data Source=" & datasource 'Set ado = conADO If IsMissing(ds) Then Set gADO = GetConnection Else Set gADO = GetConnection(ds) End If 'Else ' Set conADO = ADO End If 'myConnection.Open ' Determine if we conected. If gADO.State = adStateOpen Then 'MsgBox "Welcome to the Biblio Database!" Else MsgBox "The connection could not be made." End If '@todo handle timeout -2147467259 Set rs = gADO.Execute(sSQL) '@todo: I got -2147467259 and [DataDirect][ODBC Sybase Wire Protocol driver]Timeout exceeded. On Error Resume Next If rs.EOF Then RunQuery2 = 0 Else RunQuery2 = rs(0) End If 'If IsMissing(ADO) Then ' gADO.Close 'End If rs.Close Set rs = Nothing End Function |