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 October 19th, 2003, 01:01 PM
farooha farooha is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Oct 2003
Posts: 3 farooha User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Please Help!

i HAVE THE SAME PROBLEM..I NEED TO FINISH MY APPLICATION BY TOMM AND AT THE LAST MIN THIS ERROR COMES UP!

Syntax error in INSERT INTO statement.

THIS IS MY CODING:

//this code sets up a connection to the database
cnnDB = "PROVIDER = MICROSOFT.JET.OLEDB.4.0"
cnnDB = cnnDB & "; DATA SOURCE = c:\Inetpub\wwwroot\flyhigh\Reservations.mdb"

//this code performs the delete function
If request.Form("Res_RecID") <> "" Then
sqlRemoveRes = "Delete from Reservations Where Res_RecID = " & request.Form("Res_RecID") & ""
Set rsRemoveRes = Server.CreateObject("ADODB.RecordSet")
rsRemoveRes.Open sqlRemoveRes, cnnDB
Response.Redirect "cancelReservations.asp"
Else
//do nothing
End If


sqlRescount = "Select Count (Res_RecID) As ResCount from Reservations"
Set rsResCount = Server.CreateObject("ADODB.RecordSet")
rsResCount.Open sqlResCount, cnnDB

If rsResCount("ResCount") <20 then
sqlGetFirstRecID = "Select Min(Res_RecID) as Res_RecID From WaitingList"
Set rsGetFirstRecID = Server.CreateObject("ADODB.RecordSet")
rsGetFirstRecID.Open sqlGetFirstRecID, cnnDB

sqlFirstRecord = "Select * from WaitingList where Res_RecID = " & rsGetFirstRecID("Res_RecID") & ""
Set rsFirstRecord = Server.CreateObject("ADODB.RecordSet")
rsFirstRecord.Open sqlFirstRecord, cnnDB

sqlTransferRecord = "Insert into Reservations (Res_Firstname, Res_Surname, Res_Homephone, Res_Mobile, Res_FlightNumber) VALUES ('" & rsFirstRecord("Res_Firstname") & "','" & rsFirstRecord("Res_Surname") & "','" & rsFirstRecord("Res_Homephone") & "','" & rsFirstRecord("Res_Mobile") & "','" & rsFirstRecord("Res_FlightNumber") & ")"
Set rsTransferRecord = Server.CreateObject("ADODB.RecordSet")
(line 132)rsTransferRecord.Open sqlTransferRecord, cnnDB

sqlRemoveWaitingRes = "Delete from WaitingList Where Res_RecID = " & rsGetFirstRecID("Res_RecID") & ""
Set rsRemoveWaitingRes = Server.CreateObject("ADODB.RecordSet")
rsRemoveWaitingRes.Open sqlRemoveWaitingRes, cnnDB
Response.Redirect "cancelReservations.asp"
Else
//do nothing
End If

____________________________________________________

tHEY SAY THE ERROR IS ON LINE 132 WHERE I stated....

PLEASE IF ANYONE KNOWS WAT COULD BE WRONG PLZE TELL ME AS IM STILL A BEGINNER AND NEED TO FINISH IT VERY SOON

THANK YOU

Reply With Quote
  #2  
Old October 19th, 2003, 08:04 PM
pda8333 pda8333 is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Sep 2003
Posts: 216 pda8333 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 8 h 6 m 31 sec
Reputation Power: 6
what is yr field name for your fields that you want to insert?
__________________
Hope this helps.

Mike
Royal Selangor Pewter

"I have not failed. I've just found 10,000 ways that won't work."
- Thomas Alva Edison (1847-1931)

Reply With Quote
  #3  
Old October 20th, 2003, 01:35 AM
farooha farooha is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Oct 2003
Posts: 3 farooha User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Res_RecID (AUTO NUMBER)

and Res_Firstname, Res_Surname.....etc etc

Reply With Quote
  #4  
Old October 20th, 2003, 07:47 AM
Tim_Lensen's Avatar
Tim_Lensen Tim_Lensen is offline
Wonder of the world
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jul 2003
Location: the Netherlands
Posts: 22 Tim_Lensen User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
First you should try outputting the sqlTransferRecord variable.

Code:
sqlTransferRecord = "Insert into Reservations (Res_Firstname, Res_Surname, Res_Homephone, Res_Mobile, Res_FlightNumber) VALUES ('" & rsFirstRecord("Res_Firstname") & "','" & rsFirstRecord("Res_Surname") & "','" & rsFirstRecord("Res_Homephone") & "','" & rsFirstRecord("Res_Mobile") & "','" & rsFirstRecord("Res_FlightNumber") & ")" 

Response.Write sqlTransferRecord
Response.End

Set rsTransferRecord = Server.CreateObject("ADODB.RecordSet") 
rsTransferRecord.Open sqlTransferRecord, cnnDB 


Now look at the result. Is there something unusual, are data types the same etcetera. You can also post the result here.

good luck,
Tim

P.S. I found your error but left my message for the debugging technique. Your error is caused becasue you forgot a ' al the way at the end so it should be

...,'" & rsFirstRecord("Res_FlightNumber") & "')"

Last edited by Tim_Lensen : October 20th, 2003 at 07:49 AM.

Reply With Quote
  #5  
Old October 21st, 2003, 10:56 PM
colbyw colbyw is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Oct 2003
Posts: 2 colbyw User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
I have the same problem... im guessing looking at your code that you go to ECU, and im guessing our lecturer wrote the code wrong in the exercise he gave us... wouldn't be the first time... in reply to Tim_Lensen, and farooha, the missing ' is because that field entry is numerical, and apparently shouldn't be enclosed in the ' '..? If our lecturer got that part right. An example of my code is

sqlInsertFormData = "Insert into WaitingList (Res_FirstName, Res_Surname, Res_Homephone, Res_Workphone, Res_Partysize) VALUES ('" & request.Form("Res_Firstname") & "', '" & request.Form("Res_Surname") & "', '" & request.Form("Res_Homephone") & "', '" & request.Form("Res_Workphone") & "', " & request.Form("Res_Partysize") & ")"

Set rsInsertFormData = Server.CreateObject("ADODB.RecordSet")
rsInsertFormData.Open sqlInsertFormData, cnnDB

This was the example our lecturer gave us and somewhere in the Insert into statement there is a syntax error... partysize is numerical, the rest are strings.... anyone have any idea? im so close to a lapsed deadline right now any help would be greatly appreciated.

Cheers

Reply With Quote
  #6  
Old October 22nd, 2003, 12:03 AM
colbyw colbyw is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Oct 2003
Posts: 2 colbyw User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Ok nevermind i figured it out, to farooh, just remove the ' around the numerical fields and make sure you are testing the page in question by first passing the inputs to it instead of just opening the page in your browser window. Without the values being passed first, it throws an insert error.

Reply With Quote
  #7  
Old October 22nd, 2003, 05:48 AM
farooha farooha is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Oct 2003
Posts: 3 farooha User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
thanx guys although its too late .....but now i know wat to do in the future :-)

Reply With Quote
Reply

Viewing: Dev Shed ForumsProgramming Languages - MoreASP Programming > Please Help!


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


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





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