
save objects to an Access database using ADO
Quote:
> Dave,
> It doesn't seem to matter what kind of object I use, since I've tried
> several with the same results (err: -2147352562) Invalid number of
> paramters). The line that's failing is:
> RS!MyField = MyOject
> which I've also tried as:
> RS("MyField").value = MyObject
> and:
> RS("MyField").value = AnyObject.
> Question: In your example which dataype are you using for the field in your
> database?
The database recordset contains 3 fields.
1. Autonumber
2. ReportReference using text datatype. Used for retrieving an instance of an
object.
3. ReportData using OLE Object datatype. Used for holding the binary data of
the object.
Cheers
Dave
Quote:
> Alex
> >Alex,
> >Suggest you specify what object you are refering to.
> >The following extract will save an instance of an Activereport to an OLE
> field
> >in an access db.
> >' declaring stream object to hold Binary data
> > Set .Stream = New ADODB.Stream
> > .Stream.Type = adTypeBinary
> > .Stream.Open
> >' create a temp folder if one does not exist
> > Dim fso As FileSystemObject
> > Set fso = New FileSystemObject
> > If Not fso.FolderExists(App.Path & "\Temp") Then
> > fso.CreateFolder (App.Path & "\Temp")
> > End If
> >' save the open report to a drTemp file in the temp folder
> > With Screen.ActiveForm
> > If .arv.Pages.Count > 0 Then
> > .arv.Pages.Save App.Path & "\Temp\drTemp.RDF"
> > ElseIf Not .arv.ReportSource Is Nothing Then
> > If .arv.ReportSource.Pages.Count > 0 Then
> > .arv.ReportSource.Pages.Save App.Path & "\Temp\drTemp.RDF"
> > End If
> > End If
> > End With
> >' load the temp file into the stream object
> > .Stream.LoadFromFile App.Path & "\Temp\drTemp.RDF"
> >' add a new record to the recordset
> > .Recordset.AddNew
> >' writing the data report into Field(FieldName) as binary data.
> > .Recordset.Fields(sFieldDataName).Value = .Stream.Read
> > .Recordset.Fields(sFieldReferenceName).Value = sStr
> > .Recordset.Update
> >' delete the drTemp file
> > fso.DeleteFile App.Path & "\Temp\drTemp.RDF"
> >' tidy up
> > .Stream.Close
> > Set .Stream = Nothing
> >It may help
> >Cheers
> >Dave
> >> I'm trying to save an object to an Access database using ADO in VB code.
> >> I've indicated Ole Object as the field type in Access. The problem that
> I
> >> have is saving the object.
> >> RS!Field = MyObject doesn't do the trick, nor does Set RS!Field =
> MyObject.
> >> Anyone have a clue?
> >> Thanks, Alex