Click here to Skip to main content
15,885,278 members
Please Sign up or sign in to vote.
4.00/5 (1 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.

Thanks

Here is the code:

VB
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 (?,?)"
                    cmd.Execute()
                    cn.Close()


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
Updated 10-May-13 6:09am
v3
Comments
Yuriy Loginov 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)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900