Solved

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

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

Optimizing Cloud Backup for Low Bandwidth

With cloud storage prices going down a growing number of SMBs start to use it for backup storage. Unfortunately, business data volume rarely fits the average Internet speed. This article provides an overview of main Internet speed challenges and reveals backup best practices.

Question has a verified solution.

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

Introduced in Microsoft SQL Server 2005, the Copy Database Wizard (http://msdn.microsoft.com/en-us/library/ms188664.aspx) is useful in copying databases and associated objects between SQL instances; therefore, it is a good migration and upgrade tool…
Everyone has problem when going to load data into Data warehouse (EDW). They all need to confirm that data quality is good but they don't no how to proceed. Microsoft has provided new task within SSIS 2008 called "Data Profiler Task". It solve th…
Familiarize people with the process of retrieving data from SQL Server using an Access pass-thru query. Microsoft Access is a very powerful client/server development tool. One of the ways that you can retrieve data from a SQL Server is by using a pa…
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.

932 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

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now