/// <summary>
/// 将照片转换为二进制数组
/// </summary>
/// <param name=path></param>
/// <returns></returns>
private byte[] PhotoToArray( string path )
{
FileStream stream = new FileStream( path FileModeOpen FileAccessRead ) ;
byte[] bufferPhoto =new byte[streamLength] ;
streamRead( bufferPhotoConvertToInt( streamLength ) ) ;
streamFlush();
streamClose();
return bufferPhoto ;
}
//把二进制的图片插到数据库
private void Save(byte[] image)
{
string sql = insert into table(aaaphoto) values(@aaa@photo);
SqlParameter[] param=new SqlParameter[];
param[] =new SqlParameter(@aaaSqlDbTypeInt);
param[]Value = ;
param[]= new SqlParameter(@photoSqlDbTypeImage);
param[]Value= image;
SqlConnection conn= new SqlConnection();
connConnectionString = SystemConfigurationConfigurationSettingsAppSettings[];
SqlCommand commd= new SqlCommand(sqlconn);
commdParametersAdd(param[]);
commdParametersAdd(param[]);
try
{
connOpen();
commdExecuteNonQuery();
MessageBoxShow(把图片成功的插入数据库);
}
catch(Exception ex)
{
throw ex;
}
finally
{
connClose();
}
}