November 1st, 2011, 05:52 AM
Join Date: Nov 2011
Time spent in forums: 19 m 13 sec
Reputation Power: 0
ASP 1.0 - Upload data to access database and server error
I have a website which users are required to fill out a form which populates an access 2007 database. My users keep getting adhoc Server 500 errors. I and a few others have tested the form and it has worked successfully and none of us have had the error, but it is obviously happening. My site is hosted with Fasthosts, and they are saying it is my code!
Here is a copy of my code - is anyone able to pick the holes in it and possibly diagnose the problem? I was told it might be to do with the opening and closing of the database connections, but I am not sure.
' Declaring variables
Dim forename, surname, age, address1, address2, address3, country, telephone, data_source, con, sql_insert
' A Function to check if some field entered by user is empty
If string = "" Then string = " "
ChkString = Replace(string, "'", "''")
' Receiving values from Form
forename = ChkString(Request.Form("forename"))
surname = ChkString(Request.Form("surname"))
address1 = ChkString(Request.Form("address1"))
address2 = ChkString(Request.Form("address2"))
address3 = ChkString(Request.Form("address3"))
country = ChkString(Request.Form("country"))
telephone = ChkString(Request.Form("telephone"))
data_source = "Provider=Microsoft.Jet.OLEDB.4.0; Data Source=" & _
sql_insert = "insert into users (forename, surname, address1, address2, address3, country, telephone ) values('" & forename & "', '" & surname & "', '" & address1 & "', '" & address2 & "' , '" & address3 & "', '" & country & "', '" & telephone & "')"
' Creating Connection Object and opening the database
Set con = Server.CreateObject("ADODB.Connection")
' Done. Close the connection
Set con = Nothing