Wrox Programmer Forums
|
ASP Forms As of Oct 5, 2005, this forum is now locked. Please use "Classic ASP beginner" at http://p2p.wrox.com/forum.asp?FORUM_ID=54 or "Classic ASP Professional" http://p2p.wrox.com/forum.asp?FORUM_ID=56 instead.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the ASP Forms 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 March 11th, 2004, 03:25 PM
Authorized User
 
Join Date: Jul 2003
Posts: 41
Thanks: 0
Thanked 1 Time in 1 Post
Default Inserting Records

I'm trying to get the insert working first with just the mandatory fields. Please tell me what I'm doing wrong.

<%
Dim strInsert
Dim strValues

strInsert = "uiid,company,addr,city,state,zip,phone"
strValues = Request.Form("uiid") & "," & Request.Form("company") & _
 "," & Request.Form("addr") & "," & Request.Form("city") & _
 "," & Request.Form("state") & "," & Request.Form("zip") & _
 "," & Request.Form("phone")
sSQL = "INSERT INTO vendor (" & strInsert & ") VALUES ('" & strValues & "')"
Set rs = connect.Execute(sSQL)
%>

I get the following error:
Error Type:
Microsoft JET Database Engine (0x80040E14)
Number of query values and destination fields are not the same.
/eforms/testOrder/vendor/multi_uid_results.asp, line 38


Browser Type:
Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; .NET CLR 1.1.4322)

Page:
POST 166 bytes to /eforms/testOrder/vendor/multi_uid_results.asp

POST Data:
uiid=123123123&fein=&company=A+big+Comp&attn=&addr =here&addr2=&city=Champaign&state=IL&zip=61820&cou ntry=United+States&phone=333-4444&fax=&email=&firstname=&lastname=


Line 38 = Set rs = connect.Execute(sSQL)


 
Old March 11th, 2004, 05:53 PM
Friend of Wrox
 
Join Date: Jul 2003
Posts: 112
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Looks like you have 2 extra 's here:

('" & strValues & "')"

You are quoting all values into one string...


 
Old March 17th, 2004, 09:43 AM
Authorized User
 
Join Date: Mar 2004
Posts: 11
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to aliasp Send a message via Yahoo to aliasp
Default

hi,
to make this your code working proberly you must at first
open new recordset in the table in order to store your new
values and be sure the number of values not more than the fields
in the database and no problem if less than the fields.

here is the complete code for that:

<%

set rs = create.serverobject("adodb.recordset")

ssql="insert into vendor(uiid,company,addr,city,state,zip,phone)& _
& " values(" & Request.Form("uiid") & ",'" & Request.Form("company") & "'," & _
& " '" & Request.Form("addr") & "','" & request.Form ("city") & "'," & _
& " '" & Request.Form("state") & "','" & Request.Form("zip") & "'," & _
& " '" & Request.Form("phone") & "'"

rs.open ssql,con ' making Connection and store new value in new record
%>

Reg,

Ali

ali
 
Old March 17th, 2004, 09:47 AM
Authorized User
 
Join Date: Mar 2004
Posts: 11
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to aliasp Send a message via Yahoo to aliasp
Default

Plz correct the last my posted by add ( " ) at end of below line :

ssql="insert into vendor(uiid,company,addr,city,state,zip,phone)" & _

Thanks



ali





Similar Threads
Thread Thread Starter Forum Replies Last Post
Duplicate records while inserting the data ebindia0041 .NET Framework 1.x 0 May 23rd, 2007 07:15 PM
Inserting Records Question? ersp ADO.NET 1 May 12th, 2004 09:55 AM
Inserting Returned Records [email protected] SQL Language 2 November 4th, 2003 01:05 PM
Inserting records into a databae aadz5 ASP.NET 1.0 and 1.1 Basics 1 October 19th, 2003 10:47 AM





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