0

Please tell me how to save and show Richtextbox's data in database and retrive it in saved format and which datatype should be used to save that data. i am using vb.net and MY SQL

Dr. Rajesh Rolen
  • 14,029
  • 41
  • 106
  • 178

3 Answers3

3

if your data contains image/icons or some special symbols then its better to go for BLOB otherwise you can go with varchar datatype.

Ashok Bishnoi
  • 199
  • 13
1

You can use the BLOB datatype.

UnDiUdin
  • 14,924
  • 39
  • 151
  • 249
0

Your RTF Data feild should be "Memo".

private void InsertToMemo()
{
  using (OleDbConnection oleDbConn = new OleDbConnection(@"Provider=Microsoft.Jet.OLEDB.4.0;Data Source=|DataDirectory|\AD.mdb"))
  {
    OleDbCommand oleDbCmd = new OleDbCommand("insert into Table2 values(1,'" + this.richTextBox1.Rtf + "')", oleDbConn);
    oleDbCmd.Connection.Open();
    oleDbCmd.ExecuteNonQuery();
  }
}

private void ReadFormMemo()
{
  using (OleDbConnection oleDbConn = new OleDbConnection(@"Provider=Microsoft.Jet.OLEDB.4.0;Data Source=|DataDirectory|\AD.mdb"))
  {
    OleDbCommand oleDbCmd = new OleDbCommand("select Field1 from Table2", oleDbConn);
    oleDbCmd.Connection.Open();
    OleDbDataReader oleDbDataReader = oleDbCmd.ExecuteReader();
    oleDbDataReader.Read();
    this.richTextBox2.Rtf = oleDbDataReader.GetString(0);
  }
}
webmonkey
  • 1,083
  • 1
  • 15
  • 33