Introduction
In basic ASP.NET, FCKeditor can be easily used to insert large amounts of data.
Step 1 - Download
Download the FCKeditor
from here.
Step 2 - Create Table
CREATE TABLE [dbo].[Document]
(
[Doc ID] [int] NOT NULL,
[Document] [image] NULL
CONSTRAINT [PK_Document] PRIMARY KEY CLUSTERED
(
[Doc ID] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF,
ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
)
ON [PRIMARY] TEXTIMAGE_ON [PRIMARY]
Step 3 - Initialize FCKeditor
<%@ Register Assembly="FredCK.FCKeditorV2" Namespace="FredCK.FCKeditorV2"
TagPrefix="FCKeditorV2" %>
Using the Code
Insert Information from FCKeditor
private void SaveData()
{
try
{
dc.CreateConnection();
dc.Open();
long id = dc.GetNextID("[Document]", "[Doc ID]");
string strSQL = @"INSERT INTO
[dbo].[Document]
(
[Doc ID]
,[Document]
)
VALUES
(
@id,
@Doc
)";
SqlConnection con = dc.GetConnection();
SqlCommand cmd = new SqlCommand(strSQL, con);
Byte[] rtf = new Byte[FCK.Value.Length];
rtf = Encoding.ASCII.GetBytes(FCK.Value);
SqlParameter fileContent = new SqlParameter();
fileContent.ParameterName = "@Doc";
fileContent.SqlDbType = SqlDbType.Image;
fileContent.Size = rtf.Length;
fileContent.Value = rtf;
SqlParameter vid = new SqlParameter();
vid.ParameterName = "@id";
vid.SqlDbType = SqlDbType.BigInt;
vid.Value = id;
cmd.Parameters.Add(fileContent);
cmd.Parameters.Add(vid);
cmd.ExecuteNonQuery();
}
catch (Exception ex)
{
throw ex;
}
finally
{
dc.Close();
}
}
}
Load Information from FCKeditor
private void LoadData()
{
SqlDataReader dr = null;
try
{
dc.Open();
string strSQL = @"SELECT
[Doc ID]
,[Document]
FROM
[dbo].[Document]";
dr = dc.Read(strSQL);
if (dr.HasRows)
{
dr.Read();
if (dr["Document"].ToString() != "")
{
FCK.Value = System.Text.Encoding.ASCII.GetString((Byte[])dr["Document"]);
}
}
}
catch (Exception ex)
{
}
finally
{
dc.Close();
}
}
References
History
- 12th September, 2012: Initial post
More than 8 years experience on Programming and Project implementation, I was primarily involved with projects for private organization,Govt.(Bangladesh Army,DG Health,RJSC), NGO (SEDF,WFP). Presently I am working at ICDDR,B and enhancing Hospital Management System developed by Microsoft Dynamic NAV and Windows Mobile Application 5.0
An active supporter of Open Source technology, my interested areas are ERP, IT Audit, Data warehouse, BI etc.
Playing Guitar for 15 years, my interested music style is Blues Rock,Neo Classical.
Certification
70-540:Microsoft® Windows Mobile® 5.0 - Application Development
MB7-514:Microsoft Dynamics™ NAV 5.0 C/SIDE Introduction
MB7-516:Microsoft Dynamics™ NAV 5.0 Solution Development
MB7-517:Microsoft Dynamics™ NAV 5.0 Installation and Configuration
MB7-515:Microsoft Dynamics™ NAV 5.0 Financials
70-432:Microsoft SQL Server 2008 - Implementation and Maintenance
70-450:PRO: Designing, Optimizing and Maintaining a Database Administrative Solution Using Microsoft SQL Server 2008
70-448:Microsoft SQL Server 2008, Business Intelligence Development and Maintenance
312-50:Certified Ethical Hacker
Web :http://masudparvezshabuz.appspot.com
Blog :http://masudparvezshabuz.wordpress.com
linkedin :http://www.linkedin.com/in/masudparvez