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 "Data Source=<My Server>;" & _
"Initial Catalog=<my table>;"
Set rs = New ADODB.Recordset
rs.Open "Select * from tblInItemPict", CN, adOpenKeyset, adLockOptimistic
Set mstream = New ADODB.Stream
mstream.Type = adTypeBinary
mstream.Open
mstream.LoadFromFile "Path to the JPG file"
rs.Fields("PictItem".Value = mstream.Read
rs.Update
rs.Close
CN.Close
Thanks,
Anthony
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 "Data Source=<My Server>;" & _
"Initial Catalog=<my table>;"
Set rs = New ADODB.Recordset
rs.Open "Select * from tblInItemPict", CN, adOpenKeyset, adLockOptimistic
Set mstream = New ADODB.Stream
mstream.Type = adTypeBinary
mstream.Open
mstream.LoadFromFile "Path to the JPG file"
rs.Fields("PictItem".Value = mstream.Read
rs.Update
rs.Close
CN.Close
Thanks,
Anthony