flynn Posted February 15, 2006 Posted February 15, 2006 Just as a simple test, I am trying to save html page source to a memo field in Access. The INSERT statement is: 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: "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 Quote
Nate Bross Posted February 15, 2006 Posted February 15, 2006 You need to replace the double, and single quote with 2 of the respective char. Example: sPageText = sPageText.replace("'","''") sPageText = sPageText.replace(Convert.ToChar(34), Convert.ToChar(34) & Convert.ToChar(34)) HTH Quote ~Nate� ___________________________________________ Please use the [vb]/[cs] tags on posted code. Please post solutions you find somewhere else. Follow me on Twitter here.
Administrators PlausiblyDamp Posted February 15, 2006 Administrators Posted February 15, 2006 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. Quote Posting Guidelines FAQ Post Formatting Intellectuals solve problems; geniuses prevent them. -- Albert Einstein
flynn Posted February 15, 2006 Author Posted February 15, 2006 Or alternatively use a parameterised query. String concatenation is a bad' date=' 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.[/quote'] 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. Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.