473,770 Members | 2,217 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Insert into syntax error

2 New Member
I have been trying to insert a new record into an access database and cannot get any of the scripts to work.. I can access the db and pull up/display records but cannot get one added. Please help. (info to be inserted comes from form)
Expand|Select|Wrap|Line Numbers
  1. Inserting Records :
  2. <form action="a.asp" method="post">
  3.     FirstName : <input type="text" name="FirstName"><br>
  4.     LastName : <input type="text" name="LastName"><br>
  5.     Email : <input type="text" name="Email"><br>
  6.     DateTime : <input type="text" name="DateTime"><br>
  7.     RequestDescription : <textarea name="RequestDescription" cols="20" rows="5"></textarea><br>
  8.     Rank : <input type="text" name="Rank"><br>
  9.     PhoneNumber : <input type="text" name="PhoneNumber"><br>
  10.     Section : <input type="text" name="Section"><br>
  11.     BuildingNumber : <input type="text" name="BuildingNumber"><br>
  12.     RoomNumber : <input type="text" name="RoomNumber"><br>
  13.     RequestType : <input type="text" name="RequestType"><br>
  14.  
  15.  
  16.     <input type="submit" value="submit">
  17. </form>
  18.  
Expand|Select|Wrap|Line Numbers
  1.  
  2.  
  3. <%
  4. ' Declaring variables
  5.  
  6.  
  7. Dim DateTime, PhoneNumber, Rank, LastName, FirstName, Section , BuildingNumber, RoomNumber, RequestType, Email, RequestDescription, con, sql_insert
  8.  
  9.  
  10. ' A Function to check if some field entered by user is empty
  11. Function ChkString(string)
  12.     If string = "" Then string = " "
  13.     ChkString = Replace(string, "'", "''")
  14. End Function
  15.  
  16. ' Receiving values from Form
  17. name = ChkString(Request.Form("name"))
  18. email = ChkString(Request.Form("email"))
  19. DateTime = ChkString(Request.Form("DateTime"))
  20. PhoneNumber = ChkString(Request.Form("PhoneNumber"))
  21. Rank = ChkString(Request.Form("Rank"))
  22. LastName = ChkString(Request.Form("LastName"))
  23. FirstName = ChkString(Request.Form("Section"))
  24. BuildingNumber = ChkString(Request.Form("BuildingNumber"))
  25. RequestType = ChkString(Request.Form("RequestType"))
  26. RequestDescription = ChkString(Request.Form("Request Description"))
  27.  
  28. data_source = "Provider=Microsoft.Jet.OLEDB.4.0; Data Source=" & _ 
  29. Server.MapPath("wots.mdb")
  30. sql_insert = ("INSERT INTO MasterTable ( Email, DateTime, PhoneNumber, Rank, LastName, FirstName, Section, BuildingNumber,  RequestType, RequestDescription) VALUES ('" & email & "', '" & DateTime & "', '" & PhoneNumber & "', '"& Rank &"' '"& LastName &"', '" & FirstName &"', '" & Section &"' '" & BuildingNumber &"' '" & RequestType & "' '" & RequestDescription &"' )")
  31.  
  32. ' Creating Connection Object and opening the database
  33. Set con = Server.CreateObject("ADODB.Connection")
  34. con.Open data_source
  35. con.Execute sql_insert
  36.  
  37. ' Done. Close the connection
  38. con.Close
  39. Set con = Nothing
  40. %>
  41.  
  42.  
  43.  
Aug 17 '07 #1
2 2144
damonreid
114 Recognized Expert New Member
If you place code tags around this it will be much easier to use.

Also what version of windows/access are you running?
Aug 17 '07 #2
kisalabs
2 New Member
MS access 2002 sp3 is on the server, MS access 2003 sp2 was used to create the DB

Server 2003
Aug 17 '07 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

15
7395
by: Jack | last post by:
I have a text file of data in a file (add2db.txt) where the entries are already entered on separate lines in the following form: INSERT INTO `reviews` VALUES("", "Tony's", "Lunch", "Great atmosphere. Good food.", " (Harry Houdini - 03/01/2004)"); INSERT INTO `reviews` VALUES("", "Le Chow Place", "Lunch", "yada yada", " (Herbert Hoover - 03/03/2004)"); INSERT INTO `reviews` VALUES("", "Golden Dragon", "Lunch", "Exquisite.
24
22649
by: deko | last post by:
I'm trying to log error messages and sometimes (no telling when or where) the message contains a string with double quotes. Is there a way get the query to insert the string with the double quotes? Do I need to use code to scrub each string and remove or escape the double quotes before using it in a query? The error I get is this: Error Number 3075: Syntax error (missing operator) in query expression '"credit card billed by...
7
6672
by: kosta | last post by:
hello! one of my forms communicates with a database, and is supposed to add a row to a table using an Insert statement... however, I get a 'oledb - syntax error' exception... I have double checked, and the insert works fine (tried to use it from access)... im using visual C# express 2k5... what could be wrong? thanks!
2
5734
by: Bob Alston | last post by:
I am going blind tonight but I cannot figure out the error. I get a syntax error from this sql statement, being run via vba in access 2003 insert into tbl_Volunteer_Donor in "C:\AgencySystemVer1.32.mdb" ( ,,,,,,,,,,,,,,,,,,,) select (,,,,,,,,,,,,,,,,,,,) from tbl_Volunteer_Donor in "C:\SapulpaCommunity Care NEW.mdb"; I am trying to copy the exact same fields (but not all the available
3
2313
by: MP | last post by:
Hi Posted this several hours ago to another ng but it never showed up thought i'd try here. using vb6, ado, .mdb, jet4.0, no access given table tblJob with field JobNumber text(10) 'The example I had to go by 'INSERT INTO tblCustomers (CustomerID, , )
2
8259
by: speralta | last post by:
My tired old eyes may be failing me, but the following insert statements look correct to me, but I can't seem to get a clean insert from a fairly large text file database into mysql. I was wondering if maybe I'm hitting a limit on character length per line on some insert statements that I'm trying. Here's the error messages: execute failed: You have an error in your SQL syntax. Check the manual that corresponds to your MySQL server...
5
4833
by: mabond | last post by:
Hi VB.NET 2005 Express edition Microsoft Access 2000 (SP-3) Having trouble writing an "insert into" command for a Microsoft table I'm accessing through oledb. I've tried to follow the same principle I'd use if it was an sql database but I'm getting an error telling me the syntax of the "insert into" command
2
4815
by: technocraze | last post by:
Hi guys, I have encountered this error when updating the values to the MS Acess table. Error : Update on linked table failed. ODBC sql server error Timeout expired. MS Acess is my front end and sql server is my backend server. This error occured whenever i step through and when it reaches rs.update it jux hangs down there and thereafter it shwn the aforementioned error. I am using the RecordSet properties to add the values. Can I use...
6
3469
by: rn5a | last post by:
During registration, users are supposed to enter the following details: First Name, Last Name, EMail, UserName, Password, Confirm Password, Address, City, State, Country, Zip & Phone Number. I am using MS-Access 2000 database table for this app. Note that the datatype of all the fields mentioned above are Text. Apart from the above columns, there's another column in the DB table named 'RegDateTime' whose datatype is Date/Time which is...
2
7047
josie23
by: josie23 | last post by:
Egad, I'm not a coder/programmer by nature or occupation but understand things like html and css and a small amount of perl. So, basically, I'm a perl/mysql imbecile. But, I've been trying to find syntax to insert values into a mysql database table. I'm able to use the below syntax to insert hard-coded values like 'josie' and 'smith' but can't find working syntax to insert $scalar data from another file (which is really what perl-mysql is...
0
9619
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
10260
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
10038
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8933
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7460
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5354
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5482
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4007
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3609
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.