Wrox Programmer Forums
|
Classic ASP Basics For beginner programmers starting with "classic" ASP 3, pre-".NET." 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 Basics 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 November 28th, 2005, 06:35 AM
Authorized User
 
Join Date: Nov 2005
Posts: 17
Thanks: 0
Thanked 0 Times in 0 Posts
Default ASP and MSAccess error

Hi All,

I have this script that basically takes information from an XML file and checks one condition, and then inserts it into a SQL Server Database. I need to use a access database instead, so I changes the connection string and it seems to connect to the database ok. Here is the code (its a .vbs file)


Quote:
quote:
Dim XMLDom
Dim ItemID
Dim DbConn
Dim SQLString
Dim ANArticleNode
Dim CollectionOfArticleNodes

Set XMLDom = CreateObject("MSXML2.DomDocument.4.0")
XMLDom.async = False
XMLDom.setProperty "ServerHTTPRequest", True

Set DbConn = Createobject("adodb.connection")
DbConn.open "DRIVER={Microsoft Access Driver (*.mdb)};DBQ=casinonewsxml.mdb"


'-- Load the XML data from your live URL
XMLDom.Load("http://directnews.dehavilland.co.uk/webhost.asp?wci=feed&wcp=xmlresults&wcu=172323S123 45S0S0S0S1S0S0S0S0S1S0S0S0&orderid=1")

'-- Create a reference to a collection of all Article Tags within the downloaded XML Document
Set CollectionOfArticleNodes = XMLDom.SelectNodes("InfoStreamResults/Article")

'-- Iterate the collection of Article Tags
For Each ANArticleNode in CollectionOfArticleNodes
    ItemID = ANArticleNode.SelectSingleNode("@ID").text
    Heading = ANArticleNode.SelectSingleNode("Heading").text
    Contents = ANArticleNode.SelectSingleNode("Contents").text
    sDate = ANArticleNode.SelectSingleNode("Date").text

    '-- Delete the item from the local database if it exists
    SQLString = "DELETE FROM DeHavillandNews WHERE ItemID='" & ItemID & "';"
    DbConn.Execute(SQLString)

    '-- Insert the item into the local database
    SQLString = "INSERT INTO DeHavillandNews (ItemID,Heading,Contents,Date) " _
          & "VALUES('" & ItemID & "','" & EncodeIt(Heading) & "','" & EncodeIt(Contents) & "', '" & sDate & "');"
    DbConn.Execute(SQLString)


Next


'-- Handles quotations in text
Function EncodeIt(TextString)
    TextString = Replace(CStr(TextString), "''", "'")
    TextString = Replace(TextString, "'", "''")
    EncodeIt = TextString
End Function

when I run the code I get an error on this line :

Quote:
quote:

DbConn.Execute(SQLString)
and the error says this :

Syntax Error in INSERT INTO statment.

I have also attached a screen shot of how my database is set up.

Does anyone have any ideas as to what might be going wrong with this? I really appreciate your help

Thanks

Fogo. :)


 
Old November 28th, 2005, 07:03 AM
Friend of Wrox
 
Join Date: Jul 2003
Posts: 683
Thanks: 0
Thanked 1 Time in 1 Post
Default

Hey Fogo,

You have two lines that read DbConn.Execute(SQLString) :-)

If the error is on the DELETE statement, you might need to change it to "DELETE * FROM...", if on the INSERT statement, you may need to surround the word Date with square brackets [Date].

HTH,

Chris


 
Old November 28th, 2005, 12:00 PM
Authorized User
 
Join Date: Nov 2005
Posts: 17
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Thanks Chris for the reply.

You were right in both cases - with the date issue and with the select all symbol!

Thanks for your help - its appreciated!








Similar Threads
Thread Thread Starter Forum Replies Last Post
Error in Vb with MsAccess wsivasankar Beginning VB 6 1 May 3rd, 2006 09:23 AM
Connecting to MSAccess swatishah ADO.NET 3 January 19th, 2006 12:08 AM
Secure MSAccess db ASP Data Page Integration Will Woodward Classic ASP Databases 1 October 26th, 2005 08:32 AM
MSAccess Limitations if any happygv Access 5 April 19th, 2004 08:45 PM
read-only probs in msaccess db using asp form anupamda Classic ASP Databases 1 February 10th, 2004 12:03 PM





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