110,532
社区成员
发帖
与我相关
我的任务
分享
private void dataGridView1_CellMouseDoubleClick(object sender, DataGridViewCellMouseEventArgs e)
{
id = this.dataGridView1.Rows[e.RowIndex].Cells[0].Value.ToString();
MySql.Data.MySqlClient.MySqlCommand cmd = new MySql.Data.MySqlClient.MySqlCommand();
cmd.CommandType = CommandType.Text;
cmd.CommandText = "select `data` from `test1`.`test` where `id`='"+id+"';";
System.IO.MemoryStream ms = Mysqlconn.getmemory(cmd);
this.richTextBox1.LoadFile(ms, RichTextBoxStreamType.RichText);
}
public static MemoryStream getmemory(MySqlCommand cmd)
{
int re = 0;
MySqlConnection mycon = Mysqlconn.mysqlconn(ref re);
try
{
mycon.Open();
cmd.Connection = mycon;
DbDataReader reader = cmd.ExecuteReader();
reader.Read();
long len = reader.GetBytes(0, 0, null, 0, 0);
byte[] buffer = null;
buffer = new byte[len];
System.IO.MemoryStream mstream = new System.IO.MemoryStream(buffer);
return mstream;
}
finally
{
mycon.Close();
}
}