將資料庫中二進位制資料以非同步方式寫入磁碟

2021-03-31 13:08:54 字數 1377 閱讀 5079

方式一:一次獲取,非同步寫入

///

/// 緩衝區大小

///

public const int numpixels = 512 * 512;

///

/// 將資料檔案寫入磁碟

///

///

///

public static bool  makefilewithwritelistbyadapter(string strsql,out string strerr)

strerr = "";

return true;

} class state

}static void endwritecallback(iasyncresult asyncresult)

finally

}方式二:聯機讀取,非同步寫入

///

/// 緩衝區大小

///

public const int numpixels = 512 * 512;

///

/// 將資料檔案寫入磁碟

///

///

///

public static bool  makefilewithwritelistbyreader(string strsql,out string strerr)

catch(exception err)

byte pixels = new byte[numpixels];  

oledbdatareader reader = cmd.executereader();

byteimagecontent;

//逐條處理

while(reader.read())

reader.close();

//關閉連線

if(**n.state == system.data.connectionstate.open)

strerr = "";

//釋放資源

**n.dispose();

cmd.dispose();

gc.collect();

return true; 

}class state

}static void endwritecallback(iasyncresult asyncresult)

finally

}兩種方式的比較:

方式一:適合於資料庫負載較大,二進位制資料大小已知的情況;

方式二:適合於資料庫負載較小,二進位制資料大小未知的情況;

其中:兩種方式的非同步機制都是相同的,沒有任何區別;非同步機制的優點在於充分發揮了作業系統的優點

注意:在需要對效能進行同比測試的上下文中不能採用非同步機制而必須盡量採用同步機制,以提高真實性

資料庫二進位制日誌

二進位制日誌記錄三種格式 基於 語句 記錄 statement,記錄語句,預設模式 mariadb 10.2.3 版本以下 日誌量較少 基於 行 記錄 row,記錄資料,日誌量較大,更加安全,建議使用的格式 混合模式 mixed,讓系統自行判定該基於哪種方式進行,預設模式 mariadb 10.2....

使用用VB處理MYSQL資料庫中二進位制資料問題

xp professional sp2 vb6.0 mysql5.0 mysql odbc 3.51 使用ado 將access資料庫中的表匯入到mysql資料庫中 dim adorst as new adodb.recordset mysql 資料庫的st表 dim adoact as new a...

非同步獲取遠端二進位制資料

using system using system.net using system.threading using system.text using system.io using system.drawing 非同步獲取遠端二進位制資料 王保巨集 2006 2 28 namespace rdp...