ASP Development
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
 
User Name:
Password:
Remember me
 



Go Back   Dev Articles Community ForumsProgrammingASP Development

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 November 1st, 2011, 06:52 AM
reporter reporter is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Nov 2011
Posts: 1 reporter User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 19 m 13 sec
Reputation Power: 0
ASP 1.0 - Upload data to access database and server error

Hi

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
Function ChkString(string)
If string = "" Then string = " "
ChkString = Replace(string, "'", "''")
End Function

' 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=" & _
Server.MapPath("form.mdb")

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")
con.Open data_source
con.Execute sql_insert

' Done. Close the connection
con.Close
Set con = Nothing


Response.Redirect "thank_you.html"

Reply With Quote
Reply

Viewing: Dev Articles Community ForumsProgrammingASP Development > ASP 1.0 - Upload data to access database and server error


Developer Shed Advertisers and Affiliates


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 | 
  
 


Powered by: vBulletin Version 3.0.5
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.

© 2003-2017 by Developer Shed. All rights reserved. DS Cluster - Follow our Sitemap