Wrox Programmer Forums
|
Classic ASP Databases Discuss using ASP 3 to work with data in databases, including ASP Database Setup issues from the old P2P forum on this specific subtopic. See also the book forum Beginning ASP.NET Databases for questions specific to that book. NOT for ASP.NET 1.0, 1.1, or 2.0.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Classic ASP Databases section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old January 19th, 2005, 04:59 PM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 249
Thanks: 0
Thanked 0 Times in 0 Posts
Default stored procedure dynamic insert

Hello everybody, can anybody help me out, for the life of my I cannot get this to work or figure out why this thinks @iPrintBuyerID is a varchar, I have hard coded an int value in my input parameters. I am trying to create a dynamic Insert statement because I am have 3 tables but only the table name changes the fields are all the same, so if you have a better way of doing this I would love to know, as I cannot find anything on it anywhere I have even tried using CASE to do this, nothing seems to work.

Microsoft OLE DB Provider for SQL Server error '80040e07'
Syntax error converting the varchar value ' + @iPrintBuyerID + ' to a column of data type int.


CREATE PROCEDURE sp_ModifyGetBids_AddVendor
(
@strTable varchar(50),
@iPieceID int,
@iVendorID int,
@iRepID int,
@DateNotified datetime,
@iPrintBuyerID int,
@NewBidID int OUTPUT
)
AS
EXEC('INSERT INTO ' + @strTable +
' (Piece_ID_Bids, Vendor_ID_Bids, Rep_ID_Bids, Vendor_Notified, PrintBuyer_Bids) VALUES' +
' ('' + @iPieceID + '', '' + @iVendorID + '', '' + @iRepID + '', '' + @DateNotified + '', '' + @iPrintBuyerID + '')')
SELECT @NewBidID = @@IDENTITY


AAAAGGGGHH!!!!
Mike
__________________
Peace
Mike
http://www.eclecticpixel.com
 
Old January 20th, 2005, 09:05 AM
Friend of Wrox
 
Join Date: Oct 2003
Posts: 326
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via ICQ to Santhi Send a message via MSN to Santhi
Default

Check whether iPrintBuyerID is declared as VarChar in the table.

 
Old January 20th, 2005, 10:52 AM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 249
Thanks: 0
Thanked 0 Times in 0 Posts
Default

No it's not thats what is driving me crazy, no where It is considered to be a varchar.

.CreateParameter("@iPrintBuyerID", adInteger, adParamInput, , intAdminID)

Thanks
Mike
 
Old January 21st, 2005, 12:50 AM
Friend of Wrox
 
Join Date: Oct 2003
Posts: 326
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via ICQ to Santhi Send a message via MSN to Santhi
Default

Then problem should be with your insert statement creation.Try with the below statement

'INSERT INTO ' + @strTable +
' (Piece_ID_Bids, Vendor_ID_Bids, Rep_ID_Bids, Vendor_Notified, PrintBuyer_Bids) VALUES
 (' + @iPieceID + '
, ' + @iVendorID + ', ' + @iRepID + ', ' + @DateNotified + ', ' + @iPrintBuyerID + '))'






Similar Threads
Thread Thread Starter Forum Replies Last Post
Check value while insert in stored procedure Andraw SQL Server 2005 2 August 12th, 2008 09:08 AM
Dynamic stored procedure bsa SQL Server 2000 2 October 12th, 2004 10:05 PM
How do I insert stored procedure through C# nishim.attreja VB How-To 1 September 18th, 2004 01:24 AM
Stored Procedure - Dynamic Where Clause Terry_Pino BOOK: Professional SQL Server Reporting Services ISBN: 0-7645-6878-7 1 July 2nd, 2004 04:39 PM
Using an insert stored procedure morpheus VB How-To 3 August 7th, 2003 08:42 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.