急急急!怎么把数据库的img提出为string或者txt
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace GetImage
{
class Program
{
static void Main(string[] args)
{
private void GetImage()
{
string conn ="Server=(local);User id =sa;Pwd =huiheng518;dataset =test";
SqlConnection sqlCon = new Sqlconnection(conn);
string sql = "SELECT id,pic From Piclist where id=1";
SqlCommand myCommand = new SqlCommand();
myCommand.Connection = sqlCon;
myCommand.CommandType = CommandType.Text;
myCommand.CommandText = sql;
DataTable myTable = new DataTable();
SqlDataAdapter myDataAda = new SqlDataAdapter();
myDataAda.SelectCommand = myCommand;
try
{
sqlCon.Open();
myDataAda.Fill(myTable);
sqlCon.Close();
if(myTable.Rows.Count>0)
{
byte[] image = (byte[])myTable.Row[0]["ImageFile"];
string ll = Encoding.Default.GetString(image);
WriteStr(@"F:\test.txt",ll);
}
}
catch(Exception ex)
{