Click here to Skip to main content
13,055,852 members (49,462 online)
Rate this:
Please Sign up or sign in to vote.
See more:
I am trying to insert a record into a table from multiple threads. It seems that if two threads are trying to do it at the same time then I get:

Multiple-step OLE DB operation generated errors. Check each OLE DB status value, if available. No work was done.

I am opening up a new database connection for each thread. It seems to work if only one thread is active. Is there something going on with locking or "set count on" or something? There are no triggers on the table.


Here is the code:

OpenBackendDatabase(cn, m_sPrivateConnectionString)
                    cmd.ActiveConnection = cn
                    cmd.ActiveConnection.CursorLocation = ADODB.CursorLocationEnum.adUseClient
                    cmd.Parameters.Append(cmd.CreateParameter("", ADODB.DataTypeEnum.adVarChar, ADODB.ParameterDirectionEnum.adParamInput, 64, sRCPTTo))
                    cmd.Parameters.Append(cmd.CreateParameter("", ADODB.DataTypeEnum.adInteger, ADODB.ParameterDirectionEnum.adParamInput, , bounce.BounceType))
                    cmd.CommandText = "insert into tblBounceLog (VERPS,BounceType) values (?,?)"

Ok, it seems the issue with threads is not the primary issue but could be something else explained below.

Strange thing is, if I convert this insert to just a simple cn.execute statement it works every time:

cn.Execute("insert into tblBounceLog (VERPS,BounceType) values ('" & sRCPTTo & "'," & bounce.BounceType & ")")

So it seems the multiple-step issue is happening only when the Command is used. Can anyone explain this or seem something that I am missing?

Thanks again
Posted 9-May-13 14:54pm
Updated 10-May-13 6:09am
yloginov 10-May-13 14:56pm
try giving your parameters names like this:
cmd.Parameters.Append(cmd.CreateParameter("@param1", ADODB.DataTypeEnum.adVarChar, ADODB.ParameterDirectionEnum.adParamInput, 64, sRCPTTo))

cmd.Parameters.Append(cmd.CreateParameter("@param2", ADODB.DataTypeEnum.adInteger, ADODB.ParameterDirectionEnum.adParamInput, , bounce.BounceType))

then when you set your command text do something like this:
cmd.CommandText = "insert into tblBounceLog (VERPS,BounceType) values (@param1,@param2)"

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Top Experts
Last 24hrsThis month

Advertise | Privacy | Mobile
Web01 | 2.8.170713.1 | Last Updated 10 May 2013
Copyright © CodeProject, 1999-2017
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100