zoukankan      html  css  js  c++  java
  • 将RichTextBox的内容直接写入数据库:

     1 将RichTextBox的内容直接写入数据库:
     2 private void button1_Click(object sender, EventArgs e)
     3 {
     4    System.IO.MemoryStream mstream = new System.IO.MemoryStream();
     5    this.richTextBox1.SaveFile(mstream, RichTextBoxStreamType.RichText);
     6    //将流转换成数组
     7    byte[] bWrite = mstream.ToArray();
     8    //将数组写入数据库
     9    System.Data.SqlClient.SqlParameter[] pram ={
    10           sqlHelper.MakeInParam("@XX",System.Data.SqlDbType.Image)
    11    };
    12    pram[0].Value = bWrite;
    13    sqlHelper.RunSql("insert into XXX (XX) values (@XX)", pram);
    14 }
    15 将数据库中的RTF读出并填充到RichTextBox
    16 private void button2_Click(object sender, EventArgs e)
    17 {
    18    //从数据库中读出数据
    19    DataTable dt=sqlHelper.GetDataTable("select XX from XXX where .....");
    20    byte[] bWrite = (byte[])dt.Rows[0][0];
    21    //将数组转换成stream
    22    System.IO.MemoryStream mstream = new System.IO.MemoryStream(bWrite, false);
    23    //将stream填充到RichTextBox
    24    this.richTextBox1.LoadFile(mstream, RichTextBoxStreamType.RichText);
    25 }
  • 相关阅读:
    Apache+Tomcat+Mysql+php整合jsp,php
    mysql数据类型详析(转)
    有向图(拓扑排序算法)
    FLEX获取GET数据
    Flex对象与组件的数据 双向绑定
    D3D学习摘记(I)中
    [转贴]深入理解Javascript闭包
    一个相当愚蠢的概念错误
    近日小记
    D3D学习摘记(I)上
  • 原文地址:https://www.cnblogs.com/endv/p/6160708.html
Copyright © 2011-2022 走看看