Current filter:
                                You should refresh the page.
                                  • Hi Team
                                    VB.NET  Web Forms
                                    I have need to Load and Save RichText from a ASPxRichEdit with my SQL .
                                    I have googled this and I can not find an Example.
                                    1 What format should colum be in my SQL. (VarChar(MAX) etc

                                    2 How to set the Properties if the ASPxRichTextEdit control.

                                    3 How to Programmatically load the data

                                    4 How to Programmatically save new data
                                    I Only want to data related to the selected record to edit and then save or if no data then save new data.
                                    Hope you can help

                                1 Solution

                                Creation Date Importance Sort by

                                Hello Ron,

                                Please refer to the ASPxRichEdit - How to save and load documents from a database example, which demonstrates how to accomplish this task.

                                You mentioned that you tried to find any example on your side, but with no success. Our Search Engine returns the aforementioned example as a second result. The first one is the KB article, which also contains a link to a similar example: search.devexpress.com - "aspxrichedit database".

                                Would you please clarify which search engine and search query you used on your side?

                                Show all comments
                                • Ron Blakemore 2 11.08.2019

                                  Hi Again

                                  Thank you for the example which I have working.

                                  BUT

                                  I have some different needs.

                                  I have a Data file of Club members which I have added Column called "Notes" as varbinary(MAX)

                                  I have Key ID Column as Integer named "SDCCID"

                                  I need to be able select the member from a ASPxGridLookup and then display the RichText in my ASPxRichEditNotes

                                  and of course be able to save it after changers.

                                  The example you have supplied is working with a UNIQUEIDENTIFIER which I don,t want.

                                  Can some one help with these changes as I have spent three days trying ti get this to work.

                                  Regards

                                  Ron Blakemore

                                • Stanley (DevExpress Support) 11.11.2019

                                  Hi Ron,

                                  I am afraid your task is not completely clear to me. It is not clear how you want to open a document in ASPxRichEdit. Do you use the ASPxRichEdit control outside the ASPxGridLookup control and need to open a document based on ASPxGridLookup's selection or is your task different? Please clarify your scenario in greater detail. It would be great if you send us your page markup and code behind illustrating your current implementation. This will help us understand your scenario and provide you with suitable recommendations faster.

                                  Thanks,
                                  Stanley

                                • Ron Blakemore 2 11.11.2019

                                  Hi Stanley

                                  Thanks for reply.

                                  Please find attached a PDF to explain what I need to do.

                                • Stanley (DevExpress Support) 11.12.2019

                                  Hi Ron,

                                  Thank you for the clarification. In this case, the approach from the ASPxRichEdit - How to save and load documents from a database example should suit your needs. The main idea of this example is to load a document from a database field to a MemoryStream object or to an array of bytes and then call the ASPxRichEdit.Open method to open the document. In your case, you need to load a document from your Notes field based on the ID field value. If you need to get ASPxGridLookup's value, use the ASPxGridLookup.Value property.

                                  Thanks,
                                  Stanley

                                • Ron Blakemore 2 11.12.2019

                                  Hi Stanley

                                  Thank you for your help BUT

                                  Your Example has a uniqueidentifier where as I use a Integer with KEY Is Identity set to "YES" (auto numbering)

                                  I have tied to change your example to meet this BUT I can not get it to work

                                  Could please make these changes for me and sent it to  me.

                                  I have spent days on this as it takes 24 Hour for your reply each time I send you these posts.

                                  My SQL database

                                  SDCCID INT Primary Key

                                  Notes    Varbinary(MAX)

                                  From the ASPxGridlookup.Value  I get the SDCCID which I can use as Public "MyNotesID"

                                  Hope you can Help

                                  REgards

                                  Ron Blakemore

                                   

                                • Ron Blakemore 2 11.12.2019

                                  I have tried this code:  Saving works BUT Loading gives me this ERROR
                                  Server Error in '/' Application.


                                  Conversion from type 'Byte()' to type 'String' is not valid. Description:  An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

                                  Exception Details:  System.InvalidCastException: Conversion from type 'Byte()' to type 'String' is not valid.

                                  Source Error:

                                  Line 65: Dim dr As DataRow Line 66: For Each dr In table.Rows Line 67: ASPxRichEditNotes.Open(dr(1), DocumentFormat.Rtf) Line 68: Next Line 69: End Sub
                                  Source File:  D:\Drive-F\Projects 2019\MySDCC-V50\MySDCC-V50\MySDCC-V50\Membership\Admin\MembersRTENotes.aspx.vb    Line:  67

                                  My CODE _ _ _ _

                                  [VB.NET]
                                  Protected Sub btnSave_Click(sender As Object, e As EventArgs) Handles btnSave.Click Dim mydataSave As String = MySQLString Dim Sqlconn As SqlConnection = New SqlConnection(mydataSave) Dim query As String = "UPDATE SDCCMembers SET Notes=@Notes WHERE SDCCID='" & MyID & "'" Dim cmd As New SqlCommand(query, Sqlconn) cmd.Parameters.AddWithValue("@Notes", Me.ASPxRichEditNotes.SaveCopy(DocumentFormat.Rtf)) cmd.Connection.Open() Try cmd.ExecuteNonQuery() Catch ex As Exception Throw New Exception("Error " + ex.Message) End Try End Sub Protected Sub btnLoad_Click(sender As Object, e As EventArgs) Handles btnLoad.Click Dim mydataS As String = MySQLString Dim cnn As SqlConnection = New SqlConnection(mydataS) cnn.Open() Dim strSelect As String = "SELECT SDCCID, Notes FROM SDCCMembers WHERE SDCCID='" & MyID & "'" Dim command As SqlCommand = New SqlCommand(strSelect, cnn) Dim da As SqlDataAdapter = New SqlDataAdapter(command) Dim table As DataTable = New DataTable da.Fill(table) cnn.Close() Dim dr As DataRow For Each dr In table.Rows ASPxRichEditNotes.Open(dr(1), DocumentFormat.Rtf) Next End Sub
                                • Ron Blakemore 2 11.12.2019

                                  Sorry I should said that the Notes Column is a VarBinary(MAX)

                                  Please read ALL my Previous Post

                                • Stanley (DevExpress Support) 11.13.2019

                                  Hello,

                                  Thank you for sharing your code with me. The most part of it looks correct except for the ASPxRichEdit.Open method call. This method has multiple overloads described here:
                                  ASPxRichEdit.Open Method

                                  As you can see, there is no overload that accepts an array of bytes as the first parameter. As a result, the "System.InvalidCastException: Conversion from type 'Byte()' to type 'String' is not valid." exception is thrown. You need to use the ASPxRichEdit.Open(String, DocumentFormat, Func<Byte[]>) overload and correctly pass parameters to the Open method to resolve the problem.

                                • Ron Blakemore 2 11.13.2019

                                  Thank you for all your help

                                  All fixed and up and working.

                                • Stanley (DevExpress Support) 11.14.2019

                                  You are welcome!