jeffrey.demulling at usbank.com
jeffrey.demulling at usbank.com
Fri Jan 27 13:31:56 CST 2006
Basics:
FE = A2K3
BE = SQL Server 2000
Problem: Using the code below want to upload into the SQL Server the file
passed into the field specified. The field being passed is an image field.
It works fine for a text or xml file but will not work if I try using an
mdb or ico file. I get the error:
Run-time error '3002': File could not be opened
and this happens on the following line:
stFile.LoadFromFile strSaveFileName
When I do this I get the error:
Call UpLoadModuleFile(1, "ModuleFile", "D:\Files - Projects\TFM
Tools\Modules\SEI Reporting\SEI Reporting.mdb",
setSQLServerConnectionApplication(2, 2))
When I do this it does not error:
Call UpLoadModuleFile(1, "ModuleFile", "D:\Files - Projects\TFM
Tools\Modules\SEI Reporting\SEI Reporting.xml",
setSQLServerConnectionApplication(2, 2))
Code trying to use:
Sub UpLoadModuleFile(intModuleNumber As Integer, strFileFieldName As
String, _
strSaveFileName As String, strConnection As String)
Dim con As New ADODB.Connection
Dim rs As New ADODB.Recordset
Dim strSQL As String
Dim stFile As ADODB.Stream
strSQL = "SELECT"
strSQL = strSQL & " tblModuleFile." & strFileFieldName
strSQL = strSQL & " FROM"
strSQL = strSQL & " tblModuleFile"
strSQL = strSQL & " WHERE"
strSQL = strSQL & " tblModuleFile.InternalModuleID=" & intModuleNumber
con = strConnection
con.Open
rs.Open strSQL, con, adOpenKeyset, adLockOptimistic
Set stFile = New ADODB.Stream
stFile.Type = adTypeBinary
stFile.Open
stFile.LoadFromFile strSaveFileName
rs.Fields(strFileFieldName).Value = stFile.Read
rs.Update
stFile.Close
rs.Close
con.Close
Set stFile = Nothing
Set rs = Nothing
Set con = Nothing
End Sub
Jeffrey F. Demulling
Project Manager
U.S. Bank Corporate Trust Services
60 Livingston Avenue
EP-MN-WS3C
St. Paul, MN 55107-2292
Ph: 651-495-3925
Fax: 651-495-8103
email: jeffrey.demulling at usbank.com
------------------------------------------------------------------------------
Electronic Privacy Notice. This e-mail, and any attachments, contains information that is, or may be, covered by electronic communications privacy laws, and is also confidential and proprietary in nature. If you are not the intended recipient, please be advised that you are legally prohibited from retaining, using, copying, distributing, or otherwise disclosing this information in any manner. Instead, please reply to the sender that you have received this communication in error, and then immediately delete it. Thank you in advance for your cooperation.
==============================================================================