This is a migrated thread and some comments may be shown as answers.

RadEditor data save in sql and then show in msword

5 Answers 294 Views
Editor
This is a migrated thread and some comments may be shown as answers.
sahil
Top achievements
Rank 1
sahil asked on 21 Aug 2009, 09:08 AM
Our client want data from radeditor is store in database (sql)
then read that data from sql into microsoft word??

How can we read data from sql to msword.??

If any tool for that then,
 please can you tell me what tool i have to use for it?


5 Answers, 1 is accepted

Sort by
0
Svetlina Anati
Telerik team
answered on 21 Aug 2009, 01:33 PM
Hi sahil,

Straight to your question:

  1. The RadEditor control allows saving the content in a DB - a sample demo is available below:

    http://demos.telerik.com/aspnet-ajax/editor/examples/saveindatabase/defaultcs.aspx
  2. RadEditor is an HTML / XHTML editor and it does not offer direct export to MS Word because it is not offer by the browser itself. My suggestion is to search in Google for some third party HTML2DOC converter that will convert the generated by RadEditor HTML content to DOC formatting and allow you to save the content in MS Word DOC file.
Best wishes,
Svetlina
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Check out the tips for optimizing your support resource searches.
0
mike john
Top achievements
Rank 1
answered on 17 Mar 2010, 10:59 PM
Hi I am trying to insert the rad editor content to my DB however if I add a picture to the content I get an error as I have set it to be Text
see following
Imports System 
Imports System.Data 
Imports System.Configuration 
Imports System.Collections 
Imports System.Web 
Imports System.Web.Security 
Imports System.Web.UI 
Imports System.Web.UI.WebControls 
Imports System.Web.UI.WebControls.WebParts 
Imports System.Web.UI.HtmlControls 
Imports System.Data.OleDb 
Imports Telerik.Web.UI 
Imports System.Data.SqlClient 
Partial Class admins_HelpUpdate 
    Inherits System.Web.UI.Page 
    Public Sub btnInsert_Click(ByVal sender As ObjectByVal e As System.EventArgs) Handles Button1.Click 
 
        ' Check that four of the input values are not empty. If any of them 
        '  is empty, show a message to the user and rebind the DataGrid. 
        If (RadTextBoxCat.Text = "" Or RadEditor1.Text = ""Then 
            lblMsg.Visible = True 
            lblMsg.Text = "<b>ERROR: Null values not allowed all fields with * need to be compleated</b>" 
            lblMsg.Style("color") = "red" 
            Exit Sub 
        End If 
 
        'connect to database 
        Dim thisConnection As New SqlConnection("Data Source=**********;Integrated Security=True"
 
        'Create Command object 
        Dim nonqueryCommand As SqlCommand = thisConnection.CreateCommand() 
 
        Try 
 
            ' Open(Connection) 
            thisConnection.Open() 
 
            ' Create INSERT statement with named parameters 
            nonqueryCommand.CommandText = _ 
               "INSERT INTO Faq (Id, catagory, content) VALUES (@catagory, @content)" 
 
            ' Add Parameters to Command Parameters collection 
            nonqueryCommand.Parameters.Add(New SqlParameter("@catagory", SqlDbType.VarChar, 30)) 
            nonqueryCommand.Parameters("@catagory").Value = RadTextBoxCat.Text 
 
            nonqueryCommand.Parameters.Add(New SqlParameter("@content", SqlDbType.Text, 30)) 
            nonqueryCommand.Parameters("@jobName").Value = RadEditor1.Blob 
 
 
 
            nonqueryCommand.ExecuteNonQuery() 
 
 
            lblMsg.Text = "<b>Record Added</b><br>" 
            'check if id already exisits in the databse  
        Catch ex As SqlException 
            If ex.Number = 2627 Then 
                lblMsg.Visible = True 
                lblMsg.Text = "ERROR: A record already exists with " _ 
                   & "the same primary key, please refresh the page" 
            Else 
 
                lblMsg.Text = "ERROR: Could not add record, please " _ 
                   & "ensure the fields are correctly filled out" 
                lblMsg.Style("color") = "red" 
            End If 
        End Try 
        ' Close Connection 
        thisConnection.Close() 
 
        Exit Sub 
    End Sub 
End Class 
 

what types can I use other than text I have tried blob but that didn't work either rad controls 2009 Q3 version
0
Rumen
Telerik team
answered on 18 Mar 2010, 11:46 AM
Hi Mike,

One way, save the image to the server using the Image manager upload feature and save the path of the image in the database. 

You can also save the image in a DB by implementing a Custom File Browser Content Provider. The code of the provider is available in the RadControls for ASP.NET AJAX demos installation.

Kind regards,
Rumen
the Telerik team

Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
0
mike john
Top achievements
Rank 1
answered on 20 Mar 2010, 11:56 AM
Hi thanks for the help I now have the following the bit I am unsure of is
1. Telerik.Web.Examples.DBContentProvider which obviously gives an error it has an option to change it too

Telerik.Web.UI.Widgets.

 

FileBrowserContentProvider

 

or

Telerik.Web.UI.Widgets.

 

FileSystemContentProvider

 


The other part I am unsure about is how the data will get stored in the DB as you can see I am currently using
            nonqueryCommand.Parameters.Add(New SqlParameter("@content", SqlDbType.Text, 30))  
            nonqueryCommand.Parameters("@content").Value = RadEditor1.Text  
which is fin for text will this also include the image ? sorry this is all very new to me

Partial Class admins_HelpUpdate  
    Inherits System.Web.UI.Page  
    Protected Sub Page_Load(ByVal sender As ObjectByVal e As System.EventArgs)  
        RadEditor1.ImageManager.ContentProviderTypeName = GetType(Telerik.Web.Examples.DBContentProvider).AssemblyQualifiedName  
        RadEditor1.ImageManager.ViewPaths = New String() {"ROOT/Images/Faq""ROOT/Images/Faq"}  
        RadEditor1.ImageManager.UploadPaths = New String() {"ROOT/Images/Faq""ROOT/Images/Faq"}  
        RadEditor1.ImageManager.DeletePaths = New String() {"ROOT/Images/Faq""ROOT/Images/Faq"}  
    End Sub 
 
    Public Sub btnInsert_Click(ByVal sender As ObjectByVal e As System.EventArgs) Handles Button1.Click  
 
        ' Check that four of the input values are not empty. If any of them  
        '  is empty, show a message to the user and rebind the DataGrid.  
        If (RadTextBoxCat.Text = "" Or RadEditor1.Text = ""Then 
            lblMsg.Visible = True 
            lblMsg.Text = "<b>ERROR: Null values not allowed all fields with * need to be compleated</b>" 
            lblMsg.Style("color") = "red" 
            Exit Sub 
        End If 
 
        'connect to database  
        Dim thisConnection As New SqlConnection("Data Source=****\SQLEXPRESS;Initial Catalog=***;Integrated Security=True")  
 
        'Create Command object  
        Dim nonqueryCommand As SqlCommand = thisConnection.CreateCommand()  
 
        Try 
 
            ' Open(Connection)  
            thisConnection.Open()  
 
            ' Create INSERT statement with named parameters  
            nonqueryCommand.CommandText = _  
               "INSERT INTO Faq (Id, catagory, content) VALUES (@catagory, @content)" 
 
            ' Add Parameters to Command Parameters collection  
            nonqueryCommand.Parameters.Add(New SqlParameter("@catagory", SqlDbType.VarChar, 30))  
            nonqueryCommand.Parameters("@catagory").Value = RadTextBoxCat.Text  
 
            nonqueryCommand.Parameters.Add(New SqlParameter("@content", SqlDbType.Text, 30))  
            nonqueryCommand.Parameters("@content").Value = RadEditor1.Text  
 
 
 
            nonqueryCommand.ExecuteNonQuery() 
0
Fikret
Top achievements
Rank 1
answered on 24 Mar 2010, 05:32 PM

Hi Mike,

I am not quite sure what is causing the error with the Telerik.Web.Examples.DBContentProvider class on your side.. I recommend you, however, to test the project from this Code Library which uses the same implementation of the DBContentProvider. The Telerik.MDF database file can be found on your hard drive, where the Telerik examples are installed.

In reference to your main question:
In general you need to mix the solutions provided in this and this online demos and I recommend you to implement these steps in order to achieve the desired result:

  1. Store the images into a SQL table:The purpose of the DBContentProvider is to store the images to a SQL Database table. Then the images (from the database) are retrieved and served by an ASHX handler used in the demo project.
  2. Store the HTML content in database: After implementing the first step you need to integrate the solution provided in the second online demo. Please note that that you do not need to handle the images, because they are already stored in the database by the ImageManager

I hope this helps.

Best regards,
Fiko

Tags
Editor
Asked by
sahil
Top achievements
Rank 1
Answers by
Svetlina Anati
Telerik team
mike john
Top achievements
Rank 1
Rumen
Telerik team
Fikret
Top achievements
Rank 1
Share this question
or