Namespaces, classes etc. is not one of my best areas...
I have implemented the RadEditor in my existing home-made CMS tool and it's now working as expected when editing content in my SQL server database. Now, I would like to be able to upload- and insert images stored in the database but I have some difficulties to accomplish that.
I have created the "Items" table and imported the sample data in my database.
Maybe it's a really stupid question, but how do I combine the two demo examples ("Save in database", http://demos.telerik.com/aspnet-ajax/Editor/Examples/SaveInDatabase/DefaultVB.aspx and "Db file browser Content provider" http://demos.telerik.com/aspnet-ajax/Editor/Examples/DBFileBrowserContentProvider/DefaultVB.aspx) into the same .aspx file?
Should the two "sample-code-behind" be merged somehow?
4 Answers, 1 is accepted
I am not sure where the problem is.
You can certainly combine the two examples in one.
Please note that the DBFileBrowserContentProvider example codebehind consists of 2 classes.
Second class is the actual FileBrowserContentProvider implementation (which you got successfully running).
The first class is the actual page codebehind and is extremely simple - all it does is set the editor to point to the db content provider, e.g.
public partial class DefaultCS : System.Web.UI.Page
{
protected void Page_Load(object sender, System.EventArgs e)
{
RadEditor1.ImageManager.ContentProviderTypeName = typeof(DBContentProvider).AssemblyQualifiedName;
}
}
So, to combine the two examples, all you need to do is use the database save example - and configure the editor there properly to point to this
ContentProviderTypeName.
All the best,
Tervel
the Telerik team
Check out Telerik Trainer, the state of the art learning tool for Telerik products.

I have advanced a bit now, it almost works to insert images from the database now, except for the following issues:
1. The path to the inserted image is wrong, Two "//" slashes is being added in front of the image path...
2. "Upload" and "create new folder" etc. doesn't work. It seems to be a problem with the SQL-statements in the dataserver-class. The parameterized queries fails with the following error: "The scalar variable must be declared..." As far as i know, this is related to what database im using (SQL server 2005). In the GetContent() function, i've changed it as follows:
Dim command As OleDbCommand = New OleDbCommand("SELECT Content FROM Items WHERE ItemID = @ItemID", Connection)
command.Parameters.Add(
New OleDbParameter("@ItemID", itemId))
Changed @ItemID to ? instead:
Dim command As OleDbCommand = New OleDbCommand("SELECT Content FROM Items WHERE ItemID = ?", Connection)
command.Parameters.Add(
New OleDbParameter("@ItemID", itemId))
Do I need to change this in the other functions as well? If so, why?
Is there any other solutions?
I'm using the following connectionstring:
<
connectionStrings>
<
add name="ConnectionString" connectionString="Provider=SQLOLEDB;Data Source=mydatabase;Password=mypassword;User ID=myuser;Initial Catalog=mycatalog" providerName="System.Data.SqlClient"/>
</
connectionStrings>

Since i've made som further progress, I must reply to myself:
1. The path to the inserted image is wrong, Two "//" slashes is being added in front of the image path...
This is solved by removing the "~/" in web.config's key="Telerik.WebControls.EditorExamples.ItemHandler.
About the second problem, "named parameters" are not allowed when using OleDb Data Providers. It worked when i changed to using SqlClient providers instead. OleDb uses positioned parameters, like question marks "?".
I still don't understand how the Telerik sample code could work, maybe it is related to their use of Access database...?
Now it seems to be only one small problem left, no new folder is created and no files are being uploaded, and no erros occur ;-)
I think i'll give the sql profiler a go!
I applogize for the ugly post before.
We are not sure about the OleDB provider/SqlClient provider difference - with SqlClient you should be able to use named query parameters as well (http://msdn.microsoft.com/en-us/library/system.data.sqlclient.sqlcommand.parameters.aspx). Our demo is using an Access database (.mdb file, OleDB provider), which supports the named parameters (e.g. "@ItemID").
Perhaps you should try replacing all OleDb* related classes with the ones from the SqlClient namespace. For example:
OleDbCommand -> SqlCommand
OleDbParameter -> SqlParameter
...
In this case you will also need to change your connection string - for example:
<add name="ConnectionString" connectionString="Data Source=SERVER;Integrated Security=True;User Instance=True" providerName="System.Data.SqlClient"/>
Greetings,
Lini
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.