用blobfield调用 stream来传送
解决方案 »
- mysql转oracle
- Oracle动态拼接SQL语句???
- oracle问题
- pl/sql:定义一个table类型的变量,那么变量本身代表什么?
- 问题:很菜的问题 TYPE type_name IS TABLE OF {columble.column%TYPE} [NOT NULL] [INDEX BY BINARY_INTEGER];identifier
- 感谢小孬一直以来的帮助,放100为表偶谢意:)
- 创建表示出错
- 在pl/sql中,一个字符串中要套用另一个字符串要如何表示?比如 v_srt := 'select * from all_tables where owner = 'sys''?v_srt为一个字符
- 有关oracle的高级异常!
- 求一SQL,查询每笔通话数据是套餐内还是套餐外,非常感谢。
- oracle8.04在xp安装失败,请大家指点
- 求助!!请给我你们的邮箱,我把东西发过去,
Sub AppendChunkByteExample(FName As String)'Declare various variables.Dim NumChunks As Integer, RemChunkSize As IntegerDim TotalSize As Long, CurChunkByte() As ByteDim I As Integer, FNum As Integer, ChunkSize As IntegerOn Error GoTo ERRORHANDLE 'Set the size of each chunk.
ChunkSize = 10240
frmChunk.MousePointer = HOURGLASS
'Begin an add operation.
'OraDynaset.AddNew
'Clear the LONGRAW field.
'OraDynaset.Fields("IMAGE").Value = ""
'Get a free file number.
FNum = FreeFile
'Open the file.
Open FName For Binary As #FNum
'Get the total size of the file.
TotalSize = LOF(FNum)
lblSize.Caption = CStr(TotalSize)
'Set number of chunks.
NumChunks = TotalSize / ChunkSize
'Set number of remaining bytes.
RemChunkSize = TotalSize Mod ChunkSize
OraDynaset.Edit
'Loop through the file.
For I = 0 To NumChunks
'Calculate the new chunk size.
If I = NumChunks Then
ChunkSize = RemChunkSize
End If
ReDim CurChunkByte(ChunkSize)
'Read a chunk from the file.
Get #FNum, , CurChunkByte
'Append chunk to LONGRAW field.
OraDynaset.Fields("IMAGE").AppendChunkByte CurChunkByte(0), ChunkSize
'OraField.AppendChunk (CurChunkByte)
Next I
'Complete the add operation and update the database.
OraDynaset.Update
'Close the file.
Close FNum
frmChunk.MousePointer = Default
Exit Sub
ERRORHANDLE:
MsgBox Err.Number & Err.DescriptionEnd Sub'db to file
Public Function GetChunkByteExample() As String
'Declare various variables
Dim CurSize As Long, ChunkSize As Long, TotalSize As Long
Dim I, J As Long
Dim CurChunk() As Byte, DestBlob() As ByteDim tempPath As String
Dim FileName As String
Dim FileNumber As IntegerOn Error GoTo ERRORHANDLE
If tempPath = "" Then
tempPath = GetWTempPath() + "FISCTemp\"
If Dir(tempPath, vbDirectory) = "" Then
MkDir (tempPath)
End If
FileName = GetTempName(tempPath)
End If
FileNumber = FreeFile()
Open FileName For Binary As FileNumber
'Set the size of each chunk
ChunkSize = 10240
'Redim CurChunk Array
ReDim CurChunk(ChunkSize)
frmChunk.MousePointer = HOURGLASS
'Refresh the dynaset.
OraDynaset.DbRefresh
' TotalSize = OraDynaset.Fields("IMAGE").FieldSize
' lblSize.Caption = CStr(TotalSize)
I = 0
'Loop through all of the chunks
'Oracle does not return the size of columns > 64KB.
'We should loop until the length of our block is
'less than we asked for.
Do
'Get chunk from long raw field
CurSize = OraDynaset.Fields("IMAGE").DbGetChunkByte(CurChunk(0), I * ChunkSize, ChunkSize) If CurSize < ChunkSize Then
ReDim CurChunk(CurSize)
CurSize = OraDynaset.Fields("IMAGE").DbGetChunkByte(CurChunk(0), I * ChunkSize, CurSize)
End If
TotalSize = TotalSize + CurSize
lblSize.Caption = CStr(TotalSize)
'Put chunk into buffer
' For J = 0 To CurSize - 1
' DestBlob(I * ChunkSize + J) = CurChunk(J)
' Next J
Put FileNumber, , CurChunk I = I + 1
Loop Until CurSize < ChunkSize
Close FileNumber
frmChunk.MousePointer = Default
GetChunkByteExample = FileName
Exit FunctionERRORHANDLE:
MsgBox Err.Number & Err.Description
End Function
'get temp path
Public Function GetWTempPath() As StringDim tStr As String tStr = Space(255)
Call GetTempPath(256, tStr)
tStr = Trim(tStr)
While (Right(tStr, 1) <> "\")
tStr = Left(tStr, Len(tStr) - 1)
Wend
GetWTempPath = tStr
End Function'get temp file
Public Function GetTempName(Optional tempPath As String, _
Optional FirstName As String = "", Optional LastName As String = "", _
Optional ExtendName As String = ".tmp") As String
Dim tName As String
Dim Upperbound As Long, Lowerbound As Long
Dim CFlag As Boolean If tempPath = "" Then
tempPath = GetWTempPath() + "FISCTemp\"
End If
Randomize
tName = ""
Upperbound = 2147483646
Lowerbound = 0
Do
tName = tempPath & FirstName & LastName & _
CLng((Upperbound - Lowerbound + 1) * Rnd + Lowerbound) _
& ExtendName
CFlag = True
If Dir(tName) <> "" Then
CFlag = False
Exit Do
End If
Loop While (Not CFlag)
GetTempName = tNameEnd Function
vc
// 存数据到数据库中
//
SQLAllocStmt(hdbc,&hstmt);
retcode = SQLPrepare(hstmt, (BYTE *)"INSERT INTO TC13 VALUES(?,?,?,?)", SQL_NTS);
if (retcode != SQL_SUCCESS && retcode != SQL_SUCCESS_WITH_INFO)
goto ERROR_EXIT; /* Bind the parameters. For parameter 2, pass */
/* the parameter number in ParameterValuePtr instead of a buffer */
/* address. */
//绑定文件编号
retcode=SQLBindParameter(hstmt, 1, SQL_PARAM_INPUT,
SQL_C_ULONG, SQL_INTEGER,0, 0, &f_id, 0, &cbfid);
//绑定文件类型
retcode=SQLBindParameter(hstmt, 2, SQL_PARAM_INPUT,
SQL_C_CHAR, SQL_VARCHAR,0, 0, &fileType, 0, &cbfileType);
//绑定文件信息,这个是参数化,以便将来传送数据
retcode=SQLBindParameter(hstmt, 3, SQL_PARAM_INPUT,
SQL_C_ULONG, SQL_INTEGER,0, 0,(SQLPOINTER) 3, 0, &cbData);
//绑定文件长度
retcode=SQLBindParameter(hstmt, 4, SQL_PARAM_INPUT,
SQL_C_BINARY, SQL_LONGVARBINARY,
0, 0, &d_len, 0, &cbdlen);
//设置值以便在运行时向参数3传送数据
//SQL_DATA_LEN_AT_EXEC所使用的参数的长度为0
cbData = SQL_LEN_DATA_AT_EXEC(0);
//设置文件长度
d_len = size;
// d_id = 0;
retcode = SQLExecute(hstmt);
//如果要向参数发送数据
while(retcode == SQL_NEED_DATA)
{
retcode = SQLParamData(hstmt,&pToken);
if(retcode == SQL_NEED_DATA)
{
//如果文件没有结束
while(!feof(fp))
{
if((cbData=fread(Data,1,blocksize,fp))<0)
goto ERROR_EXIT; //如果读取文件出错
if(cbData==0)
break; //如果读出了0个数据
SQLPutData(hstmt,Data,cbData);//发送数据
}
}
}
/* while (retcode == SQL_SUCCESS && !feof(fp))
{
if((cbData=fread(Data,1,blocksize,fp))<0)
goto ERROR_EXIT;
if(cbData==0)
break;
d_len=cbData;
if (retcode != SQL_SUCCESS && retcode != SQL_SUCCESS_WITH_INFO)
goto ERROR_EXIT;
d_id++;
}*/
SQLFreeStmt(hstmt,SQL_DROP);
fclose(fp);
delete []Data;
return TRUE;
ERROR_EXIT:
fclose(fp);
SQLFreeStmt(hstmt,SQL_DROP);
delete []Data;
return FALSE;
}您可以参考下面的文章:Q185958 HOWTO: Use ADO GetChunk/AppendChunk with Oracle for BLOB Data
http://support.microsoft.com/support/kb/articles/q185/9/58.aspQ194975 HOWTO: Read and Write BLOBs Using GetChunk and AppendChunk
http://support.microsoft.com/support/kb/articles/q194/9/75.aspQ308448 HOW TO: Access an Oracle Database Using Visual C# .NET
http://support.microsoft.com/support/kb/articles/q308/4/48.aspQ229919 HOWTO: Retrieve a Recordset from Oracle Using ADO on ASP
http://support.microsoft.com/support/kb/articles/q229/9/19.asp