Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Pictures

Status
Not open for further replies.

APS

Vendor
Joined
Sep 25, 2000
Messages
53
Location
US
I am attempting to import pictures into a SQL 2000 database with the code posted below using a command button on a form. Before I run the code if I click on the picture object on the screen it tells me that it is empty. After I click the command button I get the following message (this is part of it) "A problem occurred while Microsoft Access was communicating with the ole server or ActiveX Control."
Can anyone tell me what I am doing wrong?

Dim CN As ADODB.Connection
Dim rs As ADODB.Recordset
Dim mstream As ADODB.Stream

Set CN = New ADODB.Connection

CN.Provider = "sqloledb"
CN.Properties("Prompt") = adPromptAlways
CN.Open &quot;Data Source=<My Server>;&quot; & _
&quot;Initial Catalog=<my table>;&quot;


Set rs = New ADODB.Recordset
rs.Open &quot;Select * from tblInItemPict&quot;, CN, adOpenKeyset, adLockOptimistic

Set mstream = New ADODB.Stream
mstream.Type = adTypeBinary
mstream.Open

mstream.LoadFromFile &quot;Path to the JPG file&quot;
rs.Fields(&quot;PictItem&quot;).Value = mstream.Read
rs.Update
rs.Close
CN.Close


Thanks,
Anthony
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top