Solved

"Multiple step OLE DB operation generate error" on MSSQL2K and ADO/Command.Execute

Posted on 2004-08-07
2
279 Views
Last Modified: 2008-02-01
I'm getting error "Multiple step OLE DB operation generate error..."
when inserting a new record into the following table:

CREATE TABLE Profession
(
  SeekerID INTEGER NOT NULL,
  SkillName NVARCHAR(30) NOT NULL,
  JobType SMALLINT,
  SubType SMALLINT,
  Prime BIT NOT NULL DEFAULT 1,
 
  PRIMARY KEY (SeekerID, SkillName),
  FOREIGN KEY (SeekerID) REFERENCES Seekers (SeekerID),
  FOREIGN KEY (JobType) REFERENCES JobTypes (TypeID),
  FOREIGN KEY (SubType) REFERENCES SubTypes (SubID),
  CHECK (JobType IS NOT NULL OR SubType IS NULL)
)

The JScript code is simple:

cmd.CommandText = "INSERT INTO Profession (SeekerID, SkillName, JobType, SubType, Prime) VALUES (?, ?, ?, ?, ?)";
cmd.CommandType = adCmdText;
cmd.Prepared = true;
cmd.Parameters.Append(cmd.CreateParameter('SeekerID', adInteger, adParamInput));
cmd.Parameters.Append(cmd.CreateParameter('SkillName', adVarWChar, adParamInput, 30));
cmd.Parameters.Append(cmd.CreateParameter('JobType', adSmallInt, adParamInput));
cmd.Parameters.Append(cmd.CreateParameter('SubType', adSmallInt, adParamInput));
cmd.Parameters.Append(cmd.CreateParameter('Prime', adBoolean, adParamInput));
cmd('SeekerID') = seeker_id;
cmd('SkillName') = pro_skillname;
cmd('JobType').Value = null;
cmd('SubType').Value = null;
cmd('Prime').Value = true;
cmd.Execute();

I'm executing a long transaction like:

con.BeginTrans()
//insert into master table
....
//delete from sub table # 1
....
//insert into sub table # 1
....

//delete from sub table # 5
....
//insert into sub table # 5
....
con.CommitTrans();

The table Profession is 3th table. I use one Command (cmd) object for all INSERT operations.
Hope Command object automatically clears its Parameters collection when CommandText
property is updated.
The DELETE operations do not use Command object because they are simple, so I use
direct con.Execute() for them.

My platform: WinXP Pro, MSSQL 2000, MDAC 2.8 and JScript 5.6

0
Comment
Question by:tumur
2 Comments
 
LVL 9

Accepted Solution

by:
crescendo earned 500 total points
ID: 11742757
I think you need to make the command object a new object each time.

Also, do you need a ".value" after cmd('SeekerID') and cmd('SkillName') or is it the default property?
0
 

Author Comment

by:tumur
ID: 11742877
Yes, Thank you! The Command's Parameters is not cleared
when a new command is assigned to CommandText.
And it does not have any method that clears above
collection. Only way is to create new Command or
delete each Parameter in the collection.
0

Featured Post

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
sql 2014,  lock limit 5 32
SQL Insert parts by customer 12 34
date diff with Fiscal Calendar 4 30
Need help constructing a conditional update query 16 46
Why is this different from all of the other step by step guides?  Because I make a living as a DBA and not as a writer and I lived through this experience. Defining the name: When I talk to people they say different names on this subject stuff l…
Ever wondered why sometimes your SQL Server is slow or unresponsive with connections spiking up but by the time you go in, all is well? The following article will show you how to install and configure a SQL job that will send you email alerts includ…
This video shows how to set up a shell script to accept a positional parameter when called, pass that to a SQL script, accept the output from the statement back and then manipulate it in the Shell.
Viewers will learn how to use the INSERT statement to insert data into their tables. It will also introduce the NULL statement, to show them what happens when no value is giving for any given column.

773 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question