Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

CFSTOREDPROC, COUNT field incorrect error

Status
Not open for further replies.

aprilius

Programmer
Apr 23, 2002
7
0
0
US
I am trying to execute a stored procedure that will insert into a table. After inserting into the first table, I want to get the id of the last record inserted, and insert into other tables using that value as a foreign key, while at the same time inserting other values. (Using CF 4.0, SQL Server 7.0) I keep getting the error: "ODBC Error Code = 07001 (Wrong number of parameters)[Microsoft][ODBC SQL Server Driver]COUNT field incorrect"


Here is the stored proc:
================================
CREATE PROCEDURE [spAddTask]

-- Purpose: Insert into tblTask table and related data into child tables: tblAssignee,tblDepartment,tblSystem,tblResource
-- Declare variables for inserts to all 4 tables

@tskTitle varchar(75),
@tskSDesc varchar(150),
@tskDDesc varchar(255),
@tskSDate datetime,
@tskEDate datetime,
@tskPriLvl smallint,
@tskStat smallint,
@tskAssignor varchar(50),
@assigneeName varchar(50),
@departmentName varchar(50),
@systemName varchar(50),
@resourceName varchar(50),
@tskID int OUTPUT

AS
begin tran

-- Insert into tblTask

INSERT INTO tblTask ([tskTitle], [tskSDesc], [tskDDesc], [tskSDate], [tskEDate], [tskPriLvl], [tskStat], [tskAssignor])
VALUES (@tskTitle, @tskSDesc, @tskDDesc, @tskSDate, @tskEDate, @tskPriLvl, @tskStat, @tskAssignor)

-- Retrieve the automatically generated tskID VALUE from the tblTask table

SET @tskID = @@IDENTITY

-- Insert new values into tblAssignee table

DECLARE @AssInsert varchar(2000)

SET @AssInsert = 'INSERT INTO tblAssignee ([tskID], [assigneeName]) VALUES (@tskID, @assigneeName)'

exec(@AssInsert)

-- Insert new values into tblResource table

DECLARE @ResInsert varchar(2000)

SET @ResInsert = 'INSERT INTO tblResource ([tskID], [resourceName]) VALUES (@tskID, @resourceName)'

exec(@ResInsert)

-- Insert new values into tblSystem table

DECLARE @SysInsert varchar(2000)

SET @SysInsert = 'INSERT INTO tblSystem ([tskID], [systemName]) VALUES (@tskID, @systemName)'

exec(@SysInsert)

-- Insert new values into tblDepartment table

DECLARE @DepInsert varchar(2000)

SET @DepInsert = 'INSERT INTO tblDepartment ([tskID], [departmentName]) VALUES (@tskID, @departmentName)'

exec(@DepInsert)

Return

commit tran

GO
=====================================

Now here is my CF code, trying to execute the stored proc:
==========================================================
Code:
<cfif IsDefined(&quot;form.cmdAdd&quot;)>
   <CFSTOREDPROC PROCEDURE=&quot;spAddTask&quot; DATASOURCE=&quot;MyCAMP_Dev&quot;>
			<CFPROCPARAM TYPE=&quot;In&quot; DBVARNAME=@tskTitle VALUE=&quot;#Trim(form.txtTaskTitle)#&quot; CFSQLTYPE=&quot;CF_SQL_VARCHAR&quot;>
			<CFPROCPARAM TYPE=&quot;In&quot; DBVARNAME=@tskSDesc VALUE=&quot;#Trim(form.txaShortDescription)#&quot; CFSQLTYPE=&quot;CF_SQL_VARCHAR&quot;>
			<CFPROCPARAM TYPE=&quot;In&quot; DBVARNAME=@tskDDesc VALUE=&quot;#Trim(form.txaDetailedDescription)#&quot; CFSQLTYPE=&quot;CF_SQL_VARCHAR&quot;>
			<CFPROCPARAM TYPE=&quot;In&quot; DBVARNAME=@tskSDate VALUE=&quot;#Trim(form.txtStartDate)#&quot; CFSQLTYPE=&quot;CF_SQL_DATE&quot;>
			<CFPROCPARAM TYPE=&quot;In&quot; DBVARNAME=@tskEDate VALUE=&quot;#Trim(form.txtEndDate)#&quot; CFSQLTYPE=&quot;CF_SQL_DATE&quot;>
			<CFPROCPARAM TYPE=&quot;In&quot; DBVARNAME=@tskPriLvl VALUE=&quot;#Trim(form.optPriorityLevel)#&quot; CFSQLTYPE=&quot;CF_SQL_SMALLINT&quot;>
			<CFPROCPARAM TYPE=&quot;In&quot; DBVARNAME=@tskStat VALUE=0 CFSQLTYPE=&quot;CF_SQL_SMALLINT&quot;>
			<CFPROCPARAM TYPE=&quot;In&quot; DBVARNAME=@tskAssignor VALUE=&quot;#NT_USER#&quot; CFSQLTYPE=&quot;CF_SQL_VARCHAR&quot;>
			<CFPROCPARAM TYPE=&quot;In&quot; DBVARNAME=@assigneeName VALUE=&quot;#Trim(form.hidTaskAssignees)#&quot; CFSQLTYPE=&quot;CF_SQL_VARCHAR&quot;>
			<CFPROCPARAM TYPE=&quot;In&quot; DBVARNAME=@departmentName VALUE=&quot;#Trim(form.txtAffectedDepartments)#&quot; CFSQLTYPE=&quot;CF_SQL_VARCHAR&quot;>
			<CFPROCPARAM TYPE=&quot;In&quot; DBVARNAME=@systemName VALUE=&quot;#Trim(form.txtAffectedSystems)#&quot; CFSQLTYPE=&quot;CF_SQL_VARCHAR&quot;>
			<CFPROCPARAM TYPE=&quot;In&quot; DBVARNAME=@resourceName VALUE=&quot;#Trim(form.txtAdditionalResources)#&quot; CFSQLTYPE=&quot;CF_SQL_VARCHAR&quot;>
			<CFPROCPARAM TYPE=&quot;Out&quot; DBVARNAME=@tskID VARIABLE=&quot;x&quot; CFSQLTYPE=&quot;CF_SQL_INTEGER&quot;>
   </CFSTOREDPROC>

<p>New task added successfully. <br><br>
<a href=&quot;maintask.cfm&quot;>Click here to view all tasks.</a></p>

<cfelse>
......
</cfif>

Thanks in advance for your help.
April
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top