Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 Development Tools
 ASP.NET
 problem in scope_identity

Author  Topic 

ejazzaslam
Starting Member

2 Posts

Posted - 2009-01-14 : 04:55:20
hello, i m use typed dataset and in query builder if i use insert command then query excute successfully , but if i user scope_identity after insert , query not passed with error " must declare @parrameter of insert command"
if i declare that parameters then query excute but i cannnot pass parrameter in the code behind file.
here is my syntax:
INSERT INTO MPS_Avg_Company1
(Company_Avg_Description, ACTIVE, CREATED_BY, CREATION_DATE,
UPDATED_BY, UPDATING_DATE, From_date, To_Date, From_Avg_Rate,
To_Avg_Rate, Staus)
VALUES (@Company_Avg_Description,@ACTIVE,@CREATED_BY,@CREATION_DATE,@UPDATED_BY,@UPDATING_DATE,@From_date,@To_Date,@From_Avg_Rate,@To_Avg_Rate,@Staus)
SELECT scope_identity()

error source: .sqlclintreader
error message: Must declare scalar variable @Company_Avg_Description

SwePeso
Patron Saint of Lost Yaks

30421 Posts

Posted - 2009-01-14 : 05:42:53
Cross post http://www.sqlteam.com/forums/topic.asp?TOPIC_ID=117793



E 12°55'05.63"
N 56°04'39.26"
Go to Top of Page

Ohmslaw
Starting Member

11 Posts

Posted - 2009-01-14 : 22:13:50
Sounds like you are using an ODBC or Access connection. You will get this error becase it does not recognize @parm. You will need to replace each parameter with ? if this is the case.

INSERT INTO MPS_Avg_Company1
(Company_Avg_Description, ACTIVE, CREATED_BY, CREATION_DATE,
UPDATED_BY, UPDATING_DATE, From_date, To_Date, From_Avg_Rate,
To_Avg_Rate, Staus)
VALUES (? ,?, ?, ?, ?, ?, ?, ?, ?, ?, ?)
SELECT scope_identity()

Then you would define your parameters for the command object in the order they are placed in you syntax.


Ohms...
Go to Top of Page
   

- Advertisement -