Wrox Programmer Forums
|
Classic ASP Basics For beginner programmers starting with "classic" ASP 3, pre-".NET." 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 Basics 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 December 29th, 2005, 09:39 PM
Authorized User
 
Join Date: Dec 2005
Posts: 61
Thanks: 0
Thanked 0 Times in 0 Posts
Default Inserting into a database

I'm trying to insert a bunch of data into a database. I'm not sure why, but it's not updating (writing). Any help is truly appreciated.


Set rsInsertRequest = Server.CreateObject("ADODB.Recordset")
objRS.ActiveConnection = MM_spgsconn_STRING

sql = "INSERT INTO PaymentHistory (" & _
"ClientID, UserID, ClientName, Name, Address, City, State, Zip, TimeStamp, Receipt, " & _
"CreditCardType, CreditCardNumber, ExpirationDate, Comment, Reference, Reference2, " & _
"Reference3, Reference4, Reference5, Amount, Fee, GrandTotal, OrderNumber, Type) " & _
"value(" & lngClientID & ", " & lngUserID & ", '" & strShortName & "', '" & varcardname & "', '" & _
varaddress1 & "', '" & varcityname & "', '" & varpostalcd & "', '" & varstatecd & "', '" & _
Now() & "', '" & strResponseReferenceNum & "', '" & varcardtype & ", '" & varcardlastfour & _
"', '" & varexpdate & "', '" & varclientref2 & " for " & varclientref3 & "', " & _
varclientref1 & "', '" & varclientref2 & "', '" & "', '" & varclientref3 & "', '" & _
varclientref4 & "', '" & varclientref5 & "') "

objrs.Open

sql=""
 
Old January 2nd, 2006, 06:04 PM
Friend of Wrox
 
Join Date: Jan 2004
Posts: 1,870
Thanks: 12
Thanked 20 Times in 20 Posts
Send a message via AIM to mat41
Default

What is your error and what DB are you inserting into? (this will help others help you)

What I can see strait away:
a..The number of fields you are inserting into does not match the number of values you have - this must match!

To resolve:
1..Ensure you have friendly errors turned off in your advanced browser settings.

2..Run and execute the statement, post the exact error

3..Run the statement and response.write the sql to the browser (but not exectue) post the sql in your next post - this way we can see the values you are attempting to insert.

FYI: the error usually tells you exactly what the problem is

Or you can strip the sql back and execute (lets say your first three fields) then add a couple and run, another couple then run... when you error out you have found your problematic value.

Wind is your friend
Matt





Similar Threads
Thread Thread Starter Forum Replies Last Post
Help in inserting to Database?? Hannibal Pro JSP 0 March 14th, 2006 07:11 AM
inserting into database shieldsteven VS.NET 2002/2003 0 November 11th, 2004 07:44 PM
inserting into database shieldsteven VS.NET 2002/2003 8 October 20th, 2004 05:33 PM
Inserting into database ZiqXx C# 6 July 5th, 2004 04:13 AM
Inserting VBNullChar into a database ipclogistics SQL Language 1 June 11th, 2004 10:10 PM





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