请帮小女子看下代码该怎么改?/要加些什么??C#

来源:百度知道 编辑:UC知道 时间:2024/06/08 19:22:49
我想要实现的功能是,在文本框中输入ID,然后将相对应的图片导出到PICTUREBOX中`~~~~

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.Data.SqlClient;
using System.IO;

namespace 二进制图片输出
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}

private void button1_Click(object sender, EventArgs e)
{
byte[] imagebytes = null;

//打开数所
SqlConnection con = new SqlConnection("Server=10.57.147.242;UID=sa;Pwd=;Database=Test");
con.Open();
SqlCommand com = new SqlCommand("select * from 图片 where FNumber='textBox1.Text' ", con);
SqlDataReader dr = com.ExecuteReader();

//查询地时候要选择一个图片的字段名
SqlCommand com = new SqlCommand("select ImgFiled from 图片 where FNumber='textBox1.Text' ", con);
SqlDataReader dr = com.ExecuteReader();
while (dr.Read())
{
imagebytes = (byte[])dr[0];//读取第一列,
}

SqlCommand com = new SqlCommand("select * from 图片 where FNumber='" + textBox1.Text+"' ", con);

还有这里,索引要改成你存放图片的列名:
imagebytes = (byte[])dr["列名"];

http://hi.baidu.com/haofefe