Saving html page source to Access

flynn

Well-known member
Joined
Jul 28, 2005
Messages
58
Just as a simple test, I am trying to save html page source to a memo field in Access. The INSERT statement is:
Code:
cmdAdd.CommandText = "INSERT INTO tblWebData (PersistentID, ArticleDate, ArticleText, sURL) VALUES" & _
          "(" & sPersistentID & "," & _
                 CDate(lvItem.SubItems(1).Text) & "," & _
                  sPageText & "," & _
                  lvItem.SubItems(3).Text & ")"

The INSERT worked before I added the sPageText variable (I tested the code by adding a blank string to the database) to the statement.

The page source contains all sorts of tick marks, quote marks and other characters typical in html. My guess is that the data is causing the exception error:

Code:
"ERROR [42000] [Microsoft][ODBC Microsoft Access Driver] Syntax error (missing operator) in query expression


Question is this: is there a way to store this data while preserving all the html?

tia,
flynn
 
You need to replace the double, and single quote with 2 of the respective char.

Example:

Code:
sPageText = sPageText.replace("","")
sPageText = sPageText.replace(Convert.ToChar(34), Convert.ToChar(34) & Convert.ToChar(34))

HTH
 
Or alternatively use a parameterised query. String concatenation is a bad, bad thing - as well as resuling in less maintainable code (like needed to manipulate strings) it also introduces the possibilty of security exploints such as injections.
 
PlausiblyDamp said:
Or alternatively use a parameterised query. String concatenation is a bad, bad thing - as well as resuling in less maintainable code (like needed to manipulate strings) it also introduces the possibilty of security exploints such as injections.

Absolutely, I agree. I was just doing a quick test to see the problems I would run into by using the "hyperlink" data type inside Access.

Thanks folks.
 
Back
Top