读取解析数据库中存放的Cuteeditor编辑的Html文件

web.config中数据库连接字符串见我的另一篇随笔: http://www.cnblogs.com/armymen1980/archive/2008/02/22/1076990.html
数据库操作类:
namespace reference
{
public class DataAccess
{
    private string strConnection = "";
    private OleDbConnection objconnection = new OleDbConnection();

    public DataAccess()
    {
        strConnection = ConfigurationManager.AppSettings["SQLConnString"].ToString() + HttpContext.Current.Server.MapPath(ConfigurationManager.AppSettings["Conn_Access"]) + ";";
        objconnection.ConnectionString = strConnection;
        objconnection.Open();
    }

    public void Command(string commtext)
    {
        OleDbCommand comm = new OleDbCommand(commtext,objconnection);    
        comm.ExecuteNonQuery();
        objconnection.Close();   
    }

    public DataSet SQLstring(string SQL)
    {
        OleDbDataAdapter objdataadapter = new OleDbDataAdapter(SQL, objconnection);
        DataSet mydataset = new DataSet();
        objdataadapter.Fill(mydataset);
        objconnection.Close();
        return mydataset;
    }
}
}
编辑好存放:
DataAccess dataconn = new DataAccess();
string cmdStr = "insert into [text](Content,Textname) values('" + Editor1.XHTML + "','" + name.Text + "')";
dataconn.Command(cmdStr);
读取解析:
DataAccess dataconn = new DataAccess();
string sql = "select * from [text]";
DataSet ds = dataconn.SQLstring(sql);
this.divContent.InnerHtml = ds.Tables[0].Rows[0]["Content"].ToString();

你可能感兴趣的:(editor)