Link to home
Start Free TrialLog in
Avatar of codefinger
codefingerFlag for United States of America

asked on

what cause stack overflow in SQLSERVER CE Update?

Assuming I do not have recursion or an infinite loop (I have checked), what should I be looking for as a possible cause of a stackoverflow exception in this line of the attached code..

SQLCeAdapter.UpdateCommand.ExecuteNonQuery()

Open in new window


Public Function UpdateSQLwithVars(ByVal strsql As String, ByVal vars As ArrayList, ByRef lex As LastException) As Boolean


        Dim SQLCeAdapter As System.Data.SqlServerCe.SqlCeDataAdapter = Nothing
        Dim sparm As SqlServerCe.SqlCeParameter
        Dim retval As Boolean = True
        Dim sqlcomm As New SqlServerCe.SqlCeCommand
        sqlcomm.Connection = _conobj
        sqlcomm.CommandText = strsql

        Try
            SQLCeAdapter = New System.Data.SqlServerCe.SqlCeDataAdapter(strsql, _conobj)
            SQLCeAdapter.UpdateCommand = sqlcomm
            For Each sparm In vars
                SQLCeAdapter.UpdateCommand.Parameters.Add(sparm)
            Next
            SQLCeAdapter.UpdateCommand.ExecuteNonQuery()

        Catch ex As Exception
            retval = False
            lex.ErrorMessage = ex.Message
            If Not ex.InnerException Is Nothing Then
                lex.ErrorMessage = lex.ErrorMessage & vbCrLf & ex.InnerException.Message
            End If

        Finally
            If Not SQLCeAdapter Is Nothing Then
                SQLCeAdapter.Dispose()
            End If

        End Try

        Return retval

    End Function

Open in new window

ASKER CERTIFIED SOLUTION
Avatar of Meir Rivkin
Meir Rivkin
Flag of Israel image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
what vars As ArrayList looks like?
Avatar of codefinger

ASKER

"UPDATE CommandCodes SET VerbalCommand = @xVerbalCommand Where CommandNo = @xCommandNo"

sqlvars(1) = New System.Data.SqlServerCe.SqlCeParameter
sqlvars(1).ParameterName = "@xVerbalCommand"
sqlvars(1).SqlDbType = System.Data.SqlDbType.NVarChar
 sqlvars(1).Value = vc.VerbalCommand    (= "Start your engine.")


sqlvars(10) = New System.Data.SqlServerCe.SqlCeParameter
sqlvars(10).ParameterName = "@xCommandNo"
sqlvars(10).SqlDbType = System.Data.SqlDbType.Int
sqlvars(10).Value = vc.CommandNo    (= 5)

vars = New ArrayList
vars.Add(sqlvars(1))
vars.Add(sqlvars(10))

CommandCodes Table:
-------------------------------------
CommandNo Int(4)
VerbalCommand nvarchar(300)


SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
It was not really the answer, but with what I gave you to work with, it was a good attempt.  ( I stated that I had checked for a circular execution in the code, but I did not check closely enough!)