Wrox Programmer Forums

Need to download code?

View our list of code downloads.

| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
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 tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Reply
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old January 19th, 2005, 04:59 PM
Friend of Wrox
 
Join Date: Jun 2003
Location: Oklahoma City, Oklahoma, USA.
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
Reply With Quote
  #2 (permalink)  
Old January 20th, 2005, 09:05 AM
Friend of Wrox
 
Join Date: Oct 2003
Location: Chennai, TamilNadu, India.
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.

Reply With Quote
  #3 (permalink)  
Old January 20th, 2005, 10:52 AM
Friend of Wrox
 
Join Date: Jun 2003
Location: Oklahoma City, Oklahoma, USA.
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
Reply With Quote
  #4 (permalink)  
Old January 21st, 2005, 12:50 AM
Friend of Wrox
 
Join Date: Oct 2003
Location: Chennai, TamilNadu, India.
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 + '))'

Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


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



All times are GMT -4. The time now is 06:32 PM.


Powered by vBulletin®
Copyright ©2000 - 2019, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.