Re: LoadRTF can't work when retrieve RTF data from database.

  •  09-10-2009, 9:58 PM

    Re: LoadRTF can't work when retrieve RTF data from database.

    Hi,Keneth:
     
         Thanks for your quick reply.
          I stored the content directly into our DB and then retrieve this content back to cuteeditor.
          I referred to the developer guide and I knew that the cuteeditor can load RTF content with the same format.
          just like this scenario:
          1) Save the Cuteeditor data as RTF.
            code snippet like this:
            -------------------------------------------------------------
            CuteEditor.Convertor.RTF.HTML2RTF html2rtf = new CuteEditor.Convertor.RTF.HTML2RTF(Editor1.Text);
            SqlConnection cnn = new SqlConnection(" Data Source=servername;Initial Catalog=database;Persist Security Info=True;");
            SqlCommand cmd = new SqlCommand(" UPDATE [TABLE] SET  [COLUMN]=@pCOLUMN WHERE ID=@pID ", cnn);
            cmd.Parameters.Add(new SqlParameter("@ppCOLUMN", SqlDbType.VarChar, 2000));
            cmd.Parameters["@pCOLUMN"].Value = html2rtf.RTF;
            cmd.Parameters.Add(new SqlParameter("@pID", SqlDbType.Int));
            cmd.Parameters["@pID"].Value = 1;
            using (cnn)
            {
                cnn.Open();
                cmd.ExecuteNonQuery();
                cnn.Close();
            }
    ----------------------------------------------------------------------
       2) And then I retrieve the data and convert to HTML.
           -------------------------------------------------
           SqlConnection cnn = new SqlConnection(" Data Source=servername;Initial Catalog=database;Persist Security Info=True;");
            SqlCommand cmd = new SqlCommand(" SELECT [COLUMN] FROM [TABLE] WHERE [ID]=@pID ", cnn);
            cmd.Parameters.Add(new SqlParameter("@pID", SqlDbType.Int));
            cmd.Parameters["@pID"].Value = 1;
            SqlDataAdapter sda = new SqlDataAdapter(cmd);
            DataSet ds = new DataSet();
            using (cnn)
            {
                cnn.Open();
                sda.Fill(ds);
                if (null != ds) Editor2.LoadRTF(ds.Tables[0].Rows[0]["COLUMN"].ToString());
                cnn.Close();
            }
           -------------------------------------------------
           Because another software just can read RTF format data,so we have no choice but store as RTF.
     
          When I debug those code, I found that the LoadRTF function will add the current path before my RTF data automatically.
          That means if my page run under http: localost:1234\CuteSoft\CuteEditor,
    and I suppose my content is "{\rtf1\ansi\ansicpg1252\deff0\deflang1033{\fonttbl{\f0\fswiss\fcharset0 Arial;}} {\*\generator Msftedit 5.41.15.1507;}\viewkind4\uc1\pard\f0\fs20 Hello\par } ";
    And the LoadRTF will get this string http: localost:1234\CuteSoft\CuteEditor\{\rtf1\ansi\ansicpg1252\deff0\deflang1033{\fonttbl{\f0\fswiss\fcharset0 Arial;}} {\*\generator Msftedit 5.41.15.1507;}\viewkind4\uc1\pard\f0\fs20 Hello\par } .
    That's the point.
    so I'm not sure if cuteeditor can support this scenario.
    Thanks for your regards.
    hery2002
View Complete Thread