Solved

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

Posted on 2004-08-07
2
282 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

Edgartown IT Case Study

Learn about Edgartown's quest to ensure the safety and security of the entire town's employee and citizen data. Read the case study!

Question has a verified solution.

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

JSON is being used more and more, besides XML, and you surely wanted to parse the data out into SQL instead of doing it in some Javascript. The below function in SQL Server can do the job for you, returning a quick table with the parsed data.
In part one, we reviewed the prerequisites required for installing SQL Server vNext. In this part we will explore how to install Microsoft's SQL Server on Ubuntu 16.04.
Via a live example, show how to setup several different housekeeping processes for a SQL Server.
Using examples as well as descriptions, and references to Books Online, show the documentation available for datatypes, explain the available data types and show how data can be passed into and out of variables.

691 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