ylard
July 27th, 2000, 09:38 AM
using a MS ACCESS database through ADO, I meet some erratic errors when copying blob from one table to a new one using the following code.
The original table contains 140000 records
dim lnev as long,fld as field, localv as variant, str1 as string,rec as ADODB.recordset
lenv = fld.ActualSize
localv = fld.GetChunk(lenv)
rec(str1).AppendChunk localv
rec.Update
it appears when I read my 'rec' Table that there is some errors (blobs are different from original one for some bits) in my blob which becomes unusable
Does anyone have same experience?
Thanks for any response
Ylard
vszilard
August 14th, 2001, 11:45 AM
you better use ADo 2.5 and stream object, and no more chunks!!
'--------------------------------------------------------------
ATENTION:
"In Access a blob is called an OLE Object data type and in SQL server it is NTEXT or IMAGE Data Type."
'-------------------------------------------------------------
ActiveX Data Objects (ADO), version 2.5
Microsoft Visual Basic Professional Edition for Windows, version 6.0
Microsoft Visual Basic Enterprise Edition for Windows, version 6.0
Microsoft OLE DB Provider for SQL Server, version 7.0
--------------------------------------------------------------------------------
Transfer the Image Stored Column in your database into a .gif File (it can be any extension you want, including way files, ..
Dim cn As ADODB.Connection
Dim rs As ADODB.Recordset
Dim mstream As ADODB.Stream
Set cn = New ADODB.Connection
cn.Open "your database name using ODBC connection" '
Set rs = New ADODB.Recordset
rs.Open "Select * from pub_info", cn, adOpenKeyset, adLockOptimistic
Set mstream = New ADODB.Stream
mstream.Type = adTypeBinary
mstream.Open
mstream.Write rs.Fields("picture").Value
mstream.SaveToFile "c:\publogo.gif", adSaveCreateOverWrite
rs.Close
cn.Close
-----------------------------------------------------------------------------------
Transfer the Image Stored in a .gif File to an Image Column in a SQL Server Table
Dim cn As ADODB.Connection
Dim rs As ADODB.Recordset
Dim mstream As ADODB.Stream
Set cn = New ADODB.Connection
cn.Open "your database name using ODBC connection" '
Set rs = New ADODB.Recordset
rs.Open "Select * from pub_info", cn, adOpenKeyset, adLockOptimistic
Set mstream = New ADODB.Stream
mstream.Type = adTypeBinary
mstream.Open
mstream.LoadFromFile ""
rs.Fields("picture").Value = mstream.Read
rs.Update
rs.Close
cn.Close
Hello, Szilard wish you the best.
You can mail me at:darkertemplar@hotmail.com
bye