ASP Programming
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsProgramming Languages - MoreASP Programming

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old February 2nd, 2004, 04:08 AM
jaspreet jaspreet is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Nov 2003
Location: DUBAI
Posts: 8 jaspreet User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 1 m 23 sec
Reputation Power: 0
Form Validation

Hi,
I am new to ASP, I am working on a web site that uses ASP and MS Access for the guestbook section.

The problem I am facing is with a form, to fill in visitor comments.
Firstly there are some field in the form that are optional and can be left blank, but when these fields are left blank and the form is submitted, I get an error saying that the length of this optional field cannot be zero.

Secondly I am having problems with inserting new rows into the database. The insert statement works fine at times and at other times gives an error saying it should be an updateable query.

This is the query:

sqlstring= "INSERT INTO comment (" &_
"ID , FirstName , LastName , Email , Country , City , Comments ) VALUES (" &_
userid & " , '" & F1 & "' , '" & F2 & "' , '" & F3 & "' , '" & F4 & "' , '" & F5 & "' , '" & F6 & "')"

con.Execute sqlstring

This was never working so I changed it to:

con.Execute sqlstring,,adCmdText + adExecuteNoRecords

This started working but now again it is not working and says that the query should be updateable.

Reply With Quote
  #2  
Old February 2nd, 2004, 07:29 PM
dc_man dc_man is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Feb 2004
Location: Stoke on Trent. Staffs England
Posts: 9 dc_man User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
The problem with the optional fields saying that they cannot be a zero length will be in the tables you created in Access. Go into design view for the table you're trying to insert the record into and check that Allow Zero Length on the optional fields is not set to No. If it is, then change it to yes.

Secondly your SQL statement has syntax errors in it....this is how it should be written.

sqlString = "Insert into tblName(ID , FirstName , LastName , Email , Country , City , Comments)" _
& " Values ('" & F1 & "', '" & F2 & "', '" & F3 & "', '" & F4 & "', '" & F5 & "', '" & F6 & "')"

I noticed that you had 7 fields you wanted to insert into, but only 6 values - which is how I've copied it. If your ID field in the database is an Autonumber field you don't need to inlude that in the fields list as it will auto-assign an id to each record for you. If it is *not* an autonumber field and you're making the ID up yourself then you need to add an extra value into the sql statement.

use the following to execute the query

set rs = con.execute(sqlstring) where rs is your recordset object variable.

Hope this helps

Reply With Quote
Reply

Viewing: Dev Shed ForumsProgramming Languages - MoreASP Programming > Form Validation


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


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

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump



 Free IT White Papers!
 
How to Present Effectively Online
This white paper offers practical and actionable advice on the key steps that any presenter should consider as they plan and execute a Webinar or online meeting.

 
Open Source Security Myths
Open Source Software (OSS) is computer software whose source code is available to the general public with relaxed or non-existent intellectual property restrictions (or arrangement such as the public domain), and is usually developed with the input of many contributors.

 
Power and Cooling Capacity Management for Data Centers
This paper describes the principles for achieving power and cooling capacity management.

 
Scalable, Fault-Tolerant NAS for Oracle - The Next Generation
For several years NAS has been evolving as a storage alternative for Oracle databases, and for good reason: NAS is quite often the simplest, most cost-effective storage approach for Oracle. Learn about the benefits that HP's approach to scalable NAS brings to Oracle environments in this comprehensive white paper.

 
Understanding Web Application Security Challenges
This white paper discusses many common threats and preventive measures for Web application security, and explains what you can do to help protect your organization.

 

Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2009 by Developer Shed. All rights reserved. DS Cluster 4 hosted by Hostway
Stay green...Green IT