Click here to Skip to main content
11,638,173 members (77,497 online)
Rate this: bad
Please Sign up or sign in to vote.
See more: ADO.NET VB.NET
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
Edited 10-May-13 6:09am
yloginov at 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
0 Sergey Alexandrovich Kryukov 314
1 302
2 stibee 253
3 Richard Deeming 180
4 Mika Wendelius 178
0 OriginalGriff 9,051
1 Sergey Alexandrovich Kryukov 8,773
2 Mika Wendelius 7,034
3 Suvendu Shekhar Giri 2,425
4 F-ES Sitecore 2,408

Advertise | Privacy | Mobile
Web02 | 2.8.150728.1 | Last Updated 10 May 2013
Copyright © CodeProject, 1999-2015
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