>If oCommand is scoped to the hit (and only referenced within that scope) then the parameter collection should be clean. But what's the scope of oParameters2 and how is it populated?
oParameters is private to the class and populated as follow:
Private oParameters As New ArrayList
Private oParameters2 As New Collection
Each parameter is added by using this method into oParameters. Then,
Public Function ParameterAdd(ByVal tcField As String, ByVal toValue As Object) As Boolean
Dim loParameter(1, 2) As Object
loParameter(1, 1) = tcField
loParameter(1, 2) = toValue
oParameters.Add(loParameter)
End Function
Then, before each SQL method from the class, this method is called to set the proper type of connection, dataadapter, command and parameters. This is where oParameters2 is then initialized accordingly to the type of connection string used.
Private Function InitializeDataObject(ByVal tcConnection As String, ByVal tcSql As String) As IDbConnection
Dim loEnumerator As IEnumerator = oParameters.GetEnumerator
Dim loParameter As Object
cConnectionString = tcConnection
cSQL = tcSql
oParameters2.Clear()
Select Case nSQLMode
Case 1
oConnection = New OleDbConnection(tcConnection)
oDataAdapter = New OleDbDataAdapter
oCommand = New OleDbCommand
While loEnumerator.MoveNext
loParameter = loEnumerator.Current
oDataParameter = New OleDbParameter("@" + loParameter(1, 1).ToString, loParameter(1, 2))
oParameters2.Add(oDataParameter)
End While
Case 2
oConnection = New SqlConnection(tcConnection)
>But, IAC, since the SELECT doesn't make use of parameters in this instance then an invalid parameter collection shouldn't cause the error.
Yes, but until we find this error, we cannot tell as there are a lot of weird reactions.
>Is MasterType a table or a view?
MasterType is a table.
>Where did the "Variable 'ADDDATE' is not found" message come from - .NET or VFP?
The backend is VFP.
>Can you put a try/catch just around some of these error points and simply STOP in the catch. The debugger might then provide clues to what goes wrong...
I will try that.