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 January 21st, 2005, 10:45 AM
Registered User
 
Join Date: Jan 2005
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
Default ASP Insert/Update code causes errors

The following insert statement causes the script to fail. When I try to run the script on my local machine and one other server it works perfectly. On others, I receive the usual HTTP 500 - Internal server error. Can anyone tell me why it works on some servers and not others?!?!

 
Code:
<%@ LANGUAGE = VBScript %>
Code:
<%  Option Explicit        %>
<%
'******************************************************************************
function RemoveCharacters()

    dim frm,item 

    Set frm = Server.CreateObject("Scripting.Dictionary")
    frm.CompareMode=1

    For each Item in Request.Form
        frm.Add Cstr(Item), Replace(Request.Form(Item),"'","''")    
    Next 

    Set RemoveCharacters = frm 
End Function
'******************************************************************************
%>
<%
    Dim ObjConn
    Dim ObjRecSet
    Dim FilePath
    Dim Statement
    Dim RMV
    Dim DateVar
    Dim TimeVar
    Dim Title

    DateVar = Date()
    TimeVar = Time()

    Set RMV = RemoveCharacters()

    'Path of Database
    FilePath = Server.MapPath("Journal.mdb")

    'Create Connection with DB
    Set ObjConn = Server.CreateObject("ADODB.Connection")
    ObjConn.open "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & FilePath

    if request("JournalAddTitle") = "" then
        Title = "Default News Title"
    else
        Title = RMV("JournalAddTitle")
    end if

    Statement = "Insert into tbl_JournalNews(JournalDate, JournalTime, JournalUser, JournalTitle, JournalNews) values('" & DateVar & "', " & TimeVar & "', '" & request("JournalAddUser") &  "', '" & Title & "', '" & RMV("JournalAddNews") & ")"
    ObjConn.Execute(Statement)


Thanks!

 
Old January 21st, 2005, 11:13 AM
Friend of Wrox
 
Join Date: Jan 2004
Posts: 303
Thanks: 0
Thanked 0 Times in 0 Posts
Default

If you want to know what error you are receiving

If you are using Internet Explorer then
Go to Tools-->Internet Options -->Advanced--> uncheck show friendly HTTP error messages

What datatype you are using for JournalDate, JournalTime columns,
datetime or text? if you are using datetime then delimiter is # in MS access instead of '

Also, Response.Write you SQL Statement

Response.Write(statement)
objConn.Execute(statement)
 
Old January 21st, 2005, 12:56 PM
Registered User
 
Join Date: Jan 2005
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Thanks shahchi1!!

I never knew I could view my errors by unchecking "show friendly HTTP error messages." I found the error message to be "Operation must use an updateable query" which most likely means I need to change the permissions on the database.

Thanks again,
Kevin

 
Old January 21st, 2005, 02:49 PM
Friend of Wrox
 
Join Date: Jan 2004
Posts: 303
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Yes, *IUSER_Machinename* must need write permission on your database. If you wanted to update database

 
Old January 25th, 2005, 04:24 AM
Registered User
 
Join Date: Jan 2005
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default

where to write the script code






Similar Threads
Thread Thread Starter Forum Replies Last Post
Insert ASP code in JS *need HELP* deean Classic ASP Basics 16 June 28th, 2008 08:57 AM
asp errors with database recordset code dhx10000 Classic ASP Professional 0 June 27th, 2006 12:30 PM
asp.net code to insert image in to database madhusrp ASP.NET 1.0 and 1.1 Professional 2 March 16th, 2006 02:54 AM
ASP code to update database on submitting form? kkbigal Classic ASP Databases 3 July 14th, 2003 05:55 AM





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