G
Guest
I'm attempting to insert data to a table via an ExecuteNonQuery call on a
SqlCommand sproc object, but I keep getting the error displayed in the
subject line and can't, for the life of me, figure out what the
ExecuteNonQuery call doesn't like. If I attempt to use the sproc from within
SQL Server Management Studio, the insert performs flawlessly.
The sproc is as follows:
ALTER PROC [dbo].[AddDrawing]
@DeptID int,
@DrawingCode smallint,
@Description varchar(60),
@Category char(4),
@ManHours decimal(5, 2),
@CaddRatio decimal(5, 2),
@CompRatio decimal(5, 2),
@LastUser varchar(20),
@NewDrawingID int output,
@NewTimeStamp timestamp output
AS
INSERT INTO ProjectDrawings (DeptID,
DrawingCode,
Description,
Category,
ManHours,
CaddRatio,
CompRatio,
LastUser)
VALUES (@DeptID,
@DrawingCode,
@Description,
@Category,
@ManHours,
@CaddRatio,
@CompRatio,
@LastUser)
SELECT @NewDrawingID = DrawingID,
@NewTimeStamp = LastChanged
FROM ProjectDrawings
RETURN
I am adding to the Parameters collection for the SqlCommand object as follows:
cm.Parameters.AddWithValue("@DeptID", _deptID);
cm.Parameters.AddWithValue("@DrawingCode", _drawingCode);
cm.Parameters.AddWithValue("@Description", _description);
cm.Parameters.AddWithValue("@Category", _category);
cm.Parameters.AddWithValue("@ManHours", _manHours);
cm.Parameters.AddWithValue("@CaddRatio", _caddRatio);
cm.Parameters.AddWithValue("@CompRatio", _compRatio);
cm.Parameters.AddWithValue("@LastUser", _lastUser);
cm.Parameters.AddWithValue("@NewDrawingID", _drawingID);
cm.Parameters["@NewDrawingID"].Direction = ParameterDirection.Output;
cm.Parameters.AddWithValue("@NewTimeStamp", _timeStamp);
cm.Parameters["@NewTimeStamp"].Direction = ParameterDirection.Output;
I use essentially the same routine for inserting values into various other
tables in my database, but this is the only one that is giving me a hard
time. What can I do to track down and correct whatever it is that's causing
me to get the error message? Any thanks will be greatly appreciated.
Allen
SqlCommand sproc object, but I keep getting the error displayed in the
subject line and can't, for the life of me, figure out what the
ExecuteNonQuery call doesn't like. If I attempt to use the sproc from within
SQL Server Management Studio, the insert performs flawlessly.
The sproc is as follows:
ALTER PROC [dbo].[AddDrawing]
@DeptID int,
@DrawingCode smallint,
@Description varchar(60),
@Category char(4),
@ManHours decimal(5, 2),
@CaddRatio decimal(5, 2),
@CompRatio decimal(5, 2),
@LastUser varchar(20),
@NewDrawingID int output,
@NewTimeStamp timestamp output
AS
INSERT INTO ProjectDrawings (DeptID,
DrawingCode,
Description,
Category,
ManHours,
CaddRatio,
CompRatio,
LastUser)
VALUES (@DeptID,
@DrawingCode,
@Description,
@Category,
@ManHours,
@CaddRatio,
@CompRatio,
@LastUser)
SELECT @NewDrawingID = DrawingID,
@NewTimeStamp = LastChanged
FROM ProjectDrawings
RETURN
I am adding to the Parameters collection for the SqlCommand object as follows:
cm.Parameters.AddWithValue("@DeptID", _deptID);
cm.Parameters.AddWithValue("@DrawingCode", _drawingCode);
cm.Parameters.AddWithValue("@Description", _description);
cm.Parameters.AddWithValue("@Category", _category);
cm.Parameters.AddWithValue("@ManHours", _manHours);
cm.Parameters.AddWithValue("@CaddRatio", _caddRatio);
cm.Parameters.AddWithValue("@CompRatio", _compRatio);
cm.Parameters.AddWithValue("@LastUser", _lastUser);
cm.Parameters.AddWithValue("@NewDrawingID", _drawingID);
cm.Parameters["@NewDrawingID"].Direction = ParameterDirection.Output;
cm.Parameters.AddWithValue("@NewTimeStamp", _timeStamp);
cm.Parameters["@NewTimeStamp"].Direction = ParameterDirection.Output;
I use essentially the same routine for inserting values into various other
tables in my database, but this is the only one that is giving me a hard
time. What can I do to track down and correct whatever it is that's causing
me to get the error message? Any thanks will be greatly appreciated.
Allen