Click here to Skip to main content
16,013,592 members
Home / Discussions / C#
   

C#

 
GeneralRe: Moving a file over a network. Pin
Heath Stewart14-Oct-04 6:38
protectorHeath Stewart14-Oct-04 6:38 
GeneralStrong name to Interop assembly Pin
hatim_ali13-Oct-04 23:44
hatim_ali13-Oct-04 23:44 
GeneralRe: Strong name to Interop assembly Pin
Alex Korchemniy14-Oct-04 9:18
Alex Korchemniy14-Oct-04 9:18 
GeneralRe: Strong name to Interop assembly Pin
hatim_ali14-Oct-04 19:19
hatim_ali14-Oct-04 19:19 
GeneralInsert RTF files in Access DB Pin
Zamolxes13-Oct-04 23:35
Zamolxes13-Oct-04 23:35 
GeneralRe: Insert RTF files in Access DB Pin
Judah Gabriel Himango14-Oct-04 5:45
sponsorJudah Gabriel Himango14-Oct-04 5:45 
GeneralRe: Insert RTF files in Access DB Pin
Heath Stewart14-Oct-04 6:35
protectorHeath Stewart14-Oct-04 6:35 
GeneralRe: Insert RTF files in Access DB Pin
Heath Stewart14-Oct-04 6:34
protectorHeath Stewart14-Oct-04 6:34 
This is most likely because your SQL expression contains a quote (as Judah said) but instead of just resorting to stored procedures (especially since Access doesn't support them), use parameterized queries.

When you use string concatenation to build SQL expressions, you not only run into problems like this but face SQL inject attacks, which are extremely easy to exploit and can be the most devastating (yeah, DDoS'ing a site sucks, but stealing credit card numbers or something else of value without the site knowing is far, far worse). If you're interested, search prior discussions on this board (heck, just go back to yesterday where I had to explain this 4 times to different people).

Something like the following would solve the problem of both escaping quotes and keeping your database secure:
using (OleDbConnection conn = new OleDbConnection(connectionString))
{
  OleDbCommand cmd = conn.CreateCommand();
  cmd.CommandText = "insert into Whatever (RTF) values (?)";
  cmd.Parameters.Add("@RTF", OleDbType.LongVarWChar).Value = richTextBox1.Rtf;
  cmd.ExecuteNonQuery();
}


This posting is provided "AS IS" with no warranties, and confers no rights.

Software Design Engineer
Developer Division Sustained Engineering
Microsoft

[My Articles] [My Blog]
QuestionTextBox - What else? Pin
pat27088113-Oct-04 22:43
pat27088113-Oct-04 22:43 
AnswerRe: TextBox - What else? Pin
Jay Shankar13-Oct-04 22:56
Jay Shankar13-Oct-04 22:56 
GeneralDictionary on cd Pin
hazzem elrefai13-Oct-04 22:38
hazzem elrefai13-Oct-04 22:38 
GeneralRe: Dictionary on cd Pin
Colin Angus Mackay13-Oct-04 22:48
Colin Angus Mackay13-Oct-04 22:48 
GeneralRe: Dictionary on cd Pin
Anonymous14-Oct-04 1:50
Anonymous14-Oct-04 1:50 
GeneralTab Control Pin
mathon13-Oct-04 21:59
mathon13-Oct-04 21:59 
GeneralRe: Tab Control Pin
Alex Korchemniy14-Oct-04 9:50
Alex Korchemniy14-Oct-04 9:50 
Generaladding combo box and data picker in DataGrid Pin
shambho13-Oct-04 21:24
shambho13-Oct-04 21:24 
GeneralAltering the word wrap in a multiline text box / rich text box Pin
Jay Shankar13-Oct-04 20:50
Jay Shankar13-Oct-04 20:50 
QuestionDesktop context menu? Pin
ting66813-Oct-04 20:48
ting66813-Oct-04 20:48 
Generalrearange combobox Pin
rolandf6913-Oct-04 20:19
rolandf6913-Oct-04 20:19 
GeneralFile Copy to network share Pin
tmonte13-Oct-04 17:44
tmonte13-Oct-04 17:44 
GeneralUniqueidentifier Pin
pat27088113-Oct-04 12:19
pat27088113-Oct-04 12:19 
GeneralRe: Uniqueidentifier Pin
Colin Angus Mackay13-Oct-04 13:42
Colin Angus Mackay13-Oct-04 13:42 
GeneralRe: Uniqueidentifier Pin
pat27088113-Oct-04 21:57
pat27088113-Oct-04 21:57 
GeneralControlling Video Streaming in a Web App Pin
El Queso13-Oct-04 11:51
El Queso13-Oct-04 11:51 
GeneralRe: Controlling Video Streaming in a Web App Pin
yoaz14-Oct-04 6:58
yoaz14-Oct-04 6:58 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.