Save Rtf from a RichTextBox into Access

  • Thread starter Thread starter Fab
  • Start date Start date
F

Fab

Hi,

How can I save the text edited in a richTextBox into a field of an Access
table.
I have an error using the following code:

OleDbCommand toto = new OleDbCommand("UPDATE Table1 SET Field1 = '" +
richTextBox1.Rtf.Replace("'","''").Trim() + "' WHERE id = 8"
toto.ExecuteNonQuery.

Field1 is a Memo type.

Thanks !
 
Hey Fab

You'll be saved a lot of grief if you used parameterized queries. Try
this:

OleDbCommand toto = new OleDbCommand("UPDATE Table1 SET Field1 = ?
WHERE id = 8");

toto.Parameters.Add(new OleDbParameter("@Field1",richTextBox1.rtf))
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top