Click here to Skip to main content
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 15:54pm
Edited 10-May-13 7: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 OriginalGriff 520
1 Maciej Los 205
2 Suvendu Shekhar Giri 159
3 Peter Leow 140
4 Kornfeld Eliyahu Peter 133
0 Sergey Alexandrovich Kryukov 9,623
1 OriginalGriff 8,895
2 Peter Leow 5,044
3 Kornfeld Eliyahu Peter 3,333
4 Maciej Los 2,561

Advertise | Privacy | Mobile
Web04 | 2.8.150327.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