![]() |
![]() | ![]() | ![]() | ![]() | ![]() | ![]() | ![]() |
| Welcome to Windows Vista Forums. Our forum is dedicated to helping you find solutions with any problems, errors or issues you are experiencing with Windows Vista. The Vista forum also covers news and updates and has an extensive Windows Vista tutorial section that covers a wide range of tips and tricks. |
| |||||||
![]() |
| |
| | #1 (permalink) |
| | SQL update problem C#, webapplication Hi usually this sql update command works fine: (html is a memo-field) UPDATE [Table1] SET [html]='content of a memo-field' WHERE [ContentID]='1' As soon as I have a content like 'winter' is colder than "summer" to assign to the html-field the sql-statement produces an error since the little signs around winter and summer are a problem for the sql-statement. Server.HtmlEncode(String) didn't help. What do I need to do, to be able to assign any text-contents to the memo-field? Thanks for your help. Patrick |
My System Specs![]() |
| | #2 (permalink) |
| | Re: SQL update problem Patrick D. wrote: Quote: > C#, webapplication > > Hi > > usually this sql update command works fine: > (html is a memo-field) > > UPDATE [Table1] SET [html]='content of a memo-field' WHERE [ContentID]='1' > > As soon as I have a content like > > 'winter' is colder than "summer" > > to assign to the html-field the sql-statement produces an error since the > little signs around winter and summer are a problem for the sql-statement. > > Server.HtmlEncode(String) didn't help. > > What do I need to do, to be able to assign any text-contents to the > memo-field? > > Thanks for your help. > > Patrick > you don't have to worry about encoding the string. UPDATE [Table1] SET [html]=? WHERE [ContentID]='1' Add a parameter to the command object. Example: cmd.Parameters.Add("", OleDbType.VarChar, 0).Value = "'winter' is colder than \"summer\""; If you can't use parameters, you have to encode the string when you put it in the query. This is done differently depending on what database you are using. Here are some of the most common: SQL Server: replace ' with '' MS Access: replace ' with '' MySQL: replace \ with \\, then replace ' with \' -- Göran Andersson _____ http://www.guffa.com |
My System Specs![]() |
![]() |
| Thread Tools | |
| |
Similar Threads | ||||
| Thread | Forum | |||
| HP UPDATE FIRMWARE update problem? | Drivers | |||
| Update Problem | Vista performance & maintenance | |||
| Comodo Firewall update addresses Windows Update problem | Vista security | |||
| Comodo Firewall update addresses Windows Update problem | Vista General | |||
| Huge problem with security update kb935902 on Windows Update | Vista General | |||