Binding a RichTextBox to an Access or SQL Server database

Hi Guys.

Does anybody know how to bind a richtextbox to a database field or otherwise read a string value from the rtb and drop it onto an INSERT query (+visa versa into UPDATE command)

What Field type is required

Any help would be great.

Thanks,

Keith.


Answer this question

Binding a RichTextBox to an Access or SQL Server database

  • mig16

    Not worked with RTB before and had not realised you had to refernece Richtextbox1.RTF instead of Richtextbox1.Text!! Stoopid me!

    Thanks for the help.


  • Jan Kučera

    And the column in SQL server 2000 must by type nvarchar (i'm using vb.net 2003 and sql Server 2000)

    It's not limited If we put a big file in richtextbox, the RTF lenght it's big.


  • James Lean

    you should be thinking of other ways of storing the text from RTB in this case, what you are doing is inefficient and will hit problems.

    I guess you could split it up into multiple columns however I strongly advice against it



  • Kannan.Perumal

    psedo code:

    Dim MySql As String = "INSERT INTO Table1 ( ID, RTF ), Values(@Id, @RTF)"

    Dim MyCommand As New System.Data.SqlClient.SqlParameter

    MyCommand.ParameterName = "@RTF"

    MyCommand.DbType = DbType.String

    MyCommand.Direction = ParameterDirection.Input

    MyCommand.SqlDbType = SqlDbType.Text

    MyCommand.Value = Me.RichTextBox1.Rtf



  • mfeo

    I guess you could just take the text from RTB and just insert it as normal into SQL table. (INSERT INTO tableName (field) VALUES (rtbValue))

    And as for retrieve it, simply do a select command and then set the rtb text to the value returned.

    does this help



  • Binding a RichTextBox to an Access or SQL Server database