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
Solved

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

Posted on 2004-08-07
2
280 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

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Slowly Changing Dimension Transformation component in data task flow is very useful for us to manage and control how data changes in SSIS.
For both online and offline retail, the cross-channel business is the most recent pattern in the B2C trade space.
This video shows, step by step, how to configure Oracle Heterogeneous Services via the Generic Gateway Agent in order to make a connection from an Oracle session and access a remote SQL Server database table.
Via a live example, show how to extract insert data into a SQL Server database table using the Import/Export option and Bulk Insert.

808 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