ADO DOT NET Posted June 11, 2007 Posted June 11, 2007 Hi When I try to save the html source of my html page inside a microsoft dhtml edit control into an Access .mdb database, I get this error: OleDb.OleDbCommand("INSERT INTO MyOwn (HTMLSource) VALUES ('" + DHTMLEditControl.DocumentHTML + "')", MyConnection) Syntax error in string in query expression ... It should be because of HTML tags, so what should I do? Any help? Thanks. Quote
Administrators PlausiblyDamp Posted June 11, 2007 Administrators Posted June 11, 2007 If the HTML contains any special SQL characters (like ' for example) then you will end up with a statement that SQL cannot parse. You will either have to encode all such characters on the way in, decode them on the way etc. Or as an alternative simply use parameterised SQL - this way you don't have to worry about special characters etc. Quote Posting Guidelines FAQ Post Formatting Intellectuals solve problems; geniuses prevent them. -- Albert Einstein
ADO DOT NET Posted June 12, 2007 Author Posted June 12, 2007 Yes html source contains both ' and " characters. You gave me 2 solutions but I was not able to understand any of them! How is encoding? Or how to use parameterised SQL? Thanks:) Quote
Administrators PlausiblyDamp Posted June 13, 2007 Administrators Posted June 13, 2007 Have a quick look at http://www.xtremedotnettalk.com/showthread.php?t=100516 hopefully it makes things clear. Quote Posting Guidelines FAQ Post Formatting Intellectuals solve problems; geniuses prevent them. -- Albert Einstein
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.