473,383 Members | 1,997 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,383 software developers and data experts.

Insert into syntax error

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 2119
damonreid
114 Expert 100+
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
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
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...
24
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...
7
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...
2
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...
3
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...
2
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...
5
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...
2
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...
6
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...
2
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...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

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.