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 Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

What is the syntax for calling a stored procedure with one parameter

Status
Not open for further replies.

OceanDesigner

Programmer
Oct 30, 2003
173
US
I have seen plenty of postings that cover this, but I am still getting a syntax error near my parameter. I could use some help sorting out the syntax. I have tried several variations of the following:
Code:
'conn is the connection variable
SQL = "Execute DeleteClaim('255001-101')"
conn.Execute(SQL)

The procedure is as follows:
Code:
CREATE PROCEDURE DeleteClaim @Claim VARCHAR(10) AS
INSERT INTO tblWarrantyDeleted SELECT * FROM tblWarranty WHERE tblWarranty.WarrantyClaimNumber = @Claim
DELETE FROM tblWarranty WHERE WarrantyClaimNumber = @Claim
GO
 
I really ment

sql = "DeleteClaim '255001-101'"

Stored procs will take named arguments or argumetns passed in by position. Parens are not required (and will cause an error)

You could also

sql = "DeleteClaim @Claim='255001-101'"

if you like the explicit stuff. The real need for explicit passing of parameters is if you want to pass them in, out of order or to omit arguments.

Not necessary but can be usefull.

Rob
 
Thanks for your help. I have tried that but I got a different error. I have now come to realize that I have an error in the stored procedure.

Thanks.
 
what is the error that you are getting..post back if you have any questions...

-DNG
 
This procedure deletes records from one of my tables, but before it does, it makes a copy to a hidden table so I can restore the record if necessary. I created new columns on the main table and did not create the same columns on the hidden table ... and I am cheating with my Select Into statement and omitting the column names (there are too many of them). I got it sorted out.

Thanks,
Jeff
 
Try adding a column list

INSERT INTO tblWarrantyDeleted [red](col1,col2,col3,col4.....)[/red] SELECT * FROM tblWarranty WHERE tblWarranty.WarrantyClaimNumber = @Claim
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top