请问如何读取sqlite数据库blob字段,生成文件
CREATE TABLE (
INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT,
VARCHAR(256),
BLOB,
INT);
;写入操作正常
_file_add(@ScriptDir & "\2.rar" ,5)
Func _file_add($file_full_path,$parent_btn_id)
Local $filename = FileGetName($file_full_path)
Local $fOpen = FileOpen($file_full_path ,16)
If $fOpen == -1 Then
FileClose($fOpen)
MsgBox(0,"","文件写入数据库出错")
Return -1
EndIf
Local $fBinaryData = FileRead($fOpen)
FileClose($fOpen)
Local $fsqliteData = _SQLite_Encode($fBinaryData)
_SQLite_Exec($hDb ,'Insert into file values (NULL,"'&$filename&'" ,'&$fsqliteData&','&$parent_btn_id&')')
EndFunc
;读出操作不正常,请问要怎么写
Local $result = _file_get_file_by_name("2.rar")
If $result <> -1 Then
Local $fOpen = FileOpen(@ScriptDir & "\dbfile.rar" ,18)
FileWrite($fOpen ,$result)
FileClose($fOpen)
EndIf
Func _file_get_file_by_name($filename)
Local $aRow
_SQLite_QuerySingleRow($hDb ,'select * from file where file_name = "' & $filename & '"',$aRow)
If IsArray($aRow) Then
Return $aRow
EndIf
MsgBox(0,"","在数据库中找不到此文件")
Return -1
EndFunc
把实参"2.rar" 前面加上@ScriptDir试试可以不? 回复 2# haijie1223
在写入的时候 file_name 字段的值就是2.rar
页:
[1]