Wrox Programmer Forums
|
Classic ASP Databases Discuss using ASP 3 to work with data in databases, including ASP Database Setup issues from the old P2P forum on this specific subtopic. See also the book forum Beginning ASP.NET Databases for questions specific to that book. NOT for ASP.NET 1.0, 1.1, or 2.0.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Classic ASP Databases section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old April 8th, 2004, 09:17 PM
Authorized User
 
Join Date: Mar 2004
Posts: 84
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via AIM to gmoney060 Send a message via MSN to gmoney060
Default adding to a database

Hello, I am starting to learn ASP and I ran into a problem that is completley stumping me. I can not figure out what is wrong! I keep on getting a "500 Internal server error"

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">

<html>
<head>
</head>
<body>
<%
   ' Declaring variables
   Dim Date, News, sql_insert

   ' Receiving values from Form
   Date = (Request.Form("Date"))
   News = (Request.Form("News"))

   data_source = "Provider=Microsoft.Jet.OLEDB.4.0; Data Source=" & _
            Server.MapPath("update_news.mdb")
   sql_insert = "insert into News (Date, News) values ('" & _Date & "', '" & News & "')"

   ' 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.Write "All records were successfully entered into the database."
 %>
</body>
</html>

if you could please email me at scoremaster25@msn.com or respond to this post with anything that could be wrong with this.

 
Old April 8th, 2004, 09:24 PM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 2,480
Thanks: 0
Thanked 1 Time in 1 Post
Default

500 Internal error, is shown because, you need to make some changes in your browser settings, I am not sure about what to be changed, so I cannot help you on that.

AFAICS, In your insert statement, you should embed the DATE value with #, as in access db, date values should be passed in the format of #DATEVALUE#. Please check Access help for passing date values during insert.

Cheers!

-Vijay G
 
Old April 8th, 2004, 09:52 PM
Authorized User
 
Join Date: Jan 2004
Posts: 47
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Go to Internet Options...Click the advanced tab...and UNcheck the "Show friendly HTTP error messages"...

This will allow you to get rid of the "500 Internal server error" message and you'll be able to see where the actual problem is!

 
Old April 8th, 2004, 10:10 PM
Authorized User
 
Join Date: Mar 2004
Posts: 84
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via AIM to gmoney060 Send a message via MSN to gmoney060
Default

Thanks for the help!
This is the acutal ASP error:


Microsoft VBScript compilation error '800a0408'

Invalid character

/add_news.asp, line 17

sql_insert = "insert into News (Date, News) values ('" & _Date & "', '" & News & "')"



 
Old April 8th, 2004, 10:17 PM
Authorized User
 
Join Date: Jan 2004
Posts: 47
Thanks: 0
Thanked 0 Times in 0 Posts
Default

I am just starting out too....and I've had SO many problems! I wish I could help you out with this problem. This website has helped me out with some of my errors...

http://www.adopenstatic.com/faq/

 
Old April 9th, 2004, 02:21 AM
Imar's Avatar
Wrox Author
 
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
Default

Hi there,

Were you trying to split your code over two lines using the _, or are you trying to use a variable called _Date?
Since Date can be a reserved word, I suggest the following fix:
Code:
' Receiving values from Form
MyDate = (Request.Form("Date"))
MyNews = (Request.Form("News"))

...
sql_insert = "insert into News (Date, News) values ('" & _
   MyDate & "', '" & MyNews & "')"
   HtH,

Imar




---------------------------------------
Imar Spaanjaars
Everyone is unique, except for me.
While typing this post, I was listening to: Schism by Tool (Track 5 from the album: Lateralus)






Similar Threads
Thread Thread Starter Forum Replies Last Post
adding new user to the database ali786 Classic ASP Databases 1 March 21st, 2005 01:34 AM
Problem with adding user to database ali786 Classic ASP Databases 3 March 11th, 2005 01:33 AM
Adding record to database? werD420 Classic ASP Databases 5 January 20th, 2005 06:27 PM
Adding data to a Database g_dub96 VB.NET 2002/2003 Basics 2 October 8th, 2003 08:18 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.