Microsoft SQL Server
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
 
User Name:
Password:
Remember me
 
Go Back   Dev Articles Community ForumsDatabasesMicrosoft SQL Server

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Display Modes
 
Unread Dev Articles Community Forums Sponsor:
  #1  
Old May 8th, 2003, 02:41 AM
HaehlPurdue HaehlPurdue is offline
Junior Member
Dev Articles Newbie (0 - 499 posts)
 
Join Date: May 2003
Location: in indiana
Posts: 1 HaehlPurdue User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Angry Can read, cant update, insert, delete

Hello - I thank anyone for help. - I have full connectivity to a database with full read write access. I have made sure several times of the names of my table and my fields and everything matches up. All the fields are of text type:

sSQL = "INSERT INTO expense " & _
"(User, Date, Code, Location, Amount, Method, Description) VALUES (" & sUser & ", " & sDate & ", " & sCode & ", " & sLocation & ", " & sAmount & ", " & sMethod & ", " & sDescription & ")"

Microsoft OLE DB Provider for ODBC Drivers (0x80040E14)
[Microsoft][ODBC Microsoft Access Driver] Syntax error in INSERT INTO statement.


Also says - (I will validate with jscript when i get the code working)

POST Data:
User=aaron&Date=1-2-2003&select=6081+-+Gas&Location=amaco&Amount=35.00&select2=CompanyCredit&Description=test



ALSO

in another page I have, I can read records just fine from the table, but cannot write, delete, or update

sSQL = "INSERT INTO used " & _
"(Make, Number, Year, PurchaseDate, Power, Miles, Hours) VALUES ('" & sMake & "', '" & sNumber & "', '" & sYear & "', '" & sPurchaseDate & "', '" & sPower & "', '" & sMiles & "', '" & sHours & "')"
response.write sSQL
Set sRS = sConn.Execute(sSQL)

Error Type:
Microsoft OLE DB Provider for ODBC Drivers (0x80040E14)
[Microsoft][ODBC Microsoft Access Driver] Syntax error in INSERT INTO statement.
/test/add.asp, line 21

POST Data:
Make=M&Number=N&Year=Y&PurchaseDate=D&Power=P&Miles=M&Hours%3C=H

************************************************** **********************

sSQL = "DELETE FROM used WHERE Number = '" & sNumber & "'"
response.write sSQL
Set sRS = sConn.Execute(sSQL)

Error Type:
Microsoft OLE DB Provider for ODBC Drivers (0x80040E14)
[Microsoft][ODBC Microsoft Access Driver] Syntax error in INSERT INTO statement.
/test/add.asp, line 21


Browser Type:
Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1)

Page:
POST 64 bytes to /test/add.asp

POST Data:
Make=M&Number=N&Year=Y&PurchaseDate=D&Power=P&Miles=M&Hours%3C=H
nancyhaehl: Error Type:
Microsoft OLE DB Provider for ODBC Drivers (0x80004005)
[Microsoft][ODBC Microsoft Access Driver] Could not delete from specified tables.
/test/delete.asp, line 14

POST Data:
number=100

************************************************** **********************

sNumber = Request.Form("Number")
sMake = Request.Form("Make")
sYear = Request.Form("Year")
sPurchaseDate = Request.Form("PurchaseDate")
sPower = Request.Form("Power")
sMiles = Request.Form("Miles")
sHours = Request.Form("Hours")
' *** Define SQL so that it updates the desired record *** '
sSQL = "UPDATE used SET " & _
"Make = " & sMake & ", " & _
"Year = " & sYear & ", " & _
"PurchaseDate = " & sPurchaseDate & ", " & _
"Power = " & sPower & ", " & _
"Miles = " & sMiles & ", " & _
"Hours = " & sHours & ", " & _
"WHERE Number = " & sNumber & ""
Set sRS = sConn.Execute(sSQL)

Error Type:
Microsoft OLE DB Provider for ODBC Drivers (0x80040E14)
[Microsoft][ODBC Microsoft Access Driver] Syntax error in UPDATE statement.
/test/update.asp, line 25

POST Data:
number=100&Make=Osh-Kosh&year=1998&purchasedate=2%2F3%2F1997&Power=Osh-Kosh&Miles=112344&Hours=12345



I would greatly appreciate any help. I can send files if need be. I have been staring at these files for a week and i am really getting frustrated. Thanks very much,

Aaron Haehl

Reply With Quote
  #2  
Old May 8th, 2003, 06:55 PM
aspnewbie aspnewbie is offline
Contributing User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Apr 2002
Location: The Great White North
Posts: 361 aspnewbie User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 58 m 50 sec
Reputation Power: 7
Send a message via MSN to aspnewbie
When you insert numbers, you don't need single quotes and when you insert strings you do.

So for example

sSQL = "DELETE FROM used WHERE Number = '" & sNumber & "'"

should be:

sSQL = "DELETE FROM used WHERE Number = " & sNumber

You didn't mention whether you were using access or SQL server. If you're using access, you should be careful about using "Number" as a field name, since it's a reserved word. You would be better renaming the field or you'll have to use [Number] in your statements. For a list of all reserved terms, see

http://www.aspfaq.com/show.asp?id=2080

Reply With Quote
Reply

Viewing: Dev Articles Community ForumsDatabasesMicrosoft SQL Server > Can read, cant update, insert, delete


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 1 hosted by Hostway