2017-09-10 12 views
-1
MySqlConnection con= new MySqlConnection("server=localhost;database=databasename;user=username;password=password"); 

string query="select *from table"; 

using (MySqlDataAdapter adpt= new MySqlDataAdapter(query,con)) 
{ 

DataSet dset= new DataSet(); 

adpt.Fill(dset); 

mytableDataGridView.DataSource=dset.Tables[0]; 

} 
con.close 

다음 코드는 varchar 및 int 데이터 만 검색 할 수 있습니다. BLOB 종류의 데이터는 검색하지 않습니다 .... plzz이 방법으로 BLOB를 읽을 수 있도록 솔루션을 제공하거나 다운로드 가능한 파일 모드가있는 다른 방법BLOB 테이블 형식의 데이터 검색

답변

0

Blob 데이터는 데이터베이스에서 바이트 배열로 읽어야합니다. 이 같은 것을해야합니다 :

FileStream fs = new FileStream(filePath, FileMode.Open, FileAccess.Read); 
BinaryReader br = new BinaryReader(fs); 
byte[] photo = br.ReadBytes((int)fs.Length);  
br.Close(); 
fs.Close(); 

여기에서 코드를 가져 왔습니다 : https://www.akadia.com/services/dotnet_read_write_blob.html. 예를 들어 화면에 BLOB를 단순히 표시하려는 경우 파일 스트림 대신 BLOB를 메모리 스트림에로드 할 수 있습니다. 그것이 사진 인 경우.