Error in insert query!!

G

Guest

Hello

I am tying to create an insert stored procedure in my access project (MSDE)
I am trying to retrieve the autonumber primary key value that is generated by the insert after this. This is my code..

INSERT INTO dbo.Ren
(Lname, Fname, RentAddress, RentPostcode, PhoneNo
VALUES (@Lname, @Fname, @Address, @Postcode, @PhoneNo
SELECT RentI
FROM dbo.Ren
WHERE (RentID = SCOPE_IDENTITY()

When i click the verify sql i get a message stating that the syntax is ok and that it has been verifed against the datasource
However when i try to save the query i get a message stating:
ADO error:Must declare the variable '@Surname

what must i do to correct this
 
M

Michel Walsh

Hi,


Try to recreate a new stored procedure. I think there is a problem with
the "management" of your actual stored procedure, after you changed it...


Hoping it may help,
Vanderghast, Access MVP




Bhavna said:
Hello,

I am tying to create an insert stored procedure in my access project (MSDE).
I am trying to retrieve the autonumber primary key value that is generated
by the insert after this. This is my code...
INSERT INTO dbo.Rent
(Lname, Fname, RentAddress, RentPostcode, PhoneNo)
VALUES (@Lname, @Fname, @Address, @Postcode, @PhoneNo)
SELECT RentID
FROM dbo.Rent
WHERE (RentID = SCOPE_IDENTITY())

When i click the verify sql i get a message stating that the syntax is ok
and that it has been verifed against the datasource.
 
H

Harvey

You use the name @lname in your code and the error is
calling for @surname. Are your names all correct?
-----Original Message-----
Hello,

I am tying to create an insert stored procedure in my access project (MSDE).
I am trying to retrieve the autonumber primary key value
that is generated by the insert after this. This is my
code...
INSERT INTO dbo.Rent
(Lname, Fname, RentAddress, RentPostcode, PhoneNo)
VALUES (@Lname, @Fname, @Address, @Postcode, @PhoneNo)
SELECT RentID
FROM dbo.Rent
WHERE (RentID = SCOPE_IDENTITY())

When i click the verify sql i get a message stating that
the syntax is ok and that it has been verifed against the
datasource.
 
F

fofa

So where is this variable @SurName? I have the feeling we are not seein
all the code here. Also are there any insert triggers on the table
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top