.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
 
Sign In
Register
 
Win Surprise Gifts!!!
Congratulations!!!


Top 5 Contributors of the Month
david stephan

Home >> Code Snippets >> Windows Form Controls >> Post New Resource Bookmark and Share   

 Subscribe to Code Snippets

Saving Formated Contents in The DataBase and Retriving The Same

Posted By:Hefin Dsouza       Posted Date: August 13, 2009    Points: 10    Category: Windows Form Controls    URL: http://www.dotnetspark.com  
 

The Code Below Will demonstrate how I save Formated Contents from a Rich Text Box to the Database and then Retrive the same in the same Formated Format.

Code For Saving The Rich Contents to the DataBase

private void Save_Data(object sender, EventArgs e)
{
OleDbCommand com = new OleDbCommand();
com.Connection = con;
com.CommandText="insert into message values(Rnd,'"+richTextBox1.Rtf +"')";
com.Connection.Open();
com.ExecuteNonQuery();
com.Clone();
}

Code For Retriving the Rich Contents to the RichTextBox From the Database

private void Get_Data(object sender, EventArgs e)
{
DataSet ds = new DataSet();
OleDbDataAdapter dap = new OleDbDataAdapter("select * from message", con);
dap.Fill(ds);
richTextBox1.Rtf = ds.Tables[0].Rows[0][1].ToString();
}

Regards
Hefin Dsouza


     

Further Readings:

Responses

No response found. Be the first to respond this post

Post Comment

You must Sign In To post reply
Find More code samples in C#, ASP.Net, Vb.Net and more Here

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend