C
Chris Cairns
I have images (qty 3) stored in the database which are used as logos on
various reports. Depending on the options the user selects different
logos may print on the report.
My problem. The data for the report comes from a stored procedure. There
are many detail lines and I really do not want to include that image with
each row in the query so I would like to be able to access it separately
since it is only needed once. When I attempt to do this I end up with
errors or nothing displayed.
My question..... Ho can I manually access an image in the sql database and
display it on a report?
I tried something like...... The control source for the object frame
would be =GetLogo(value1,value2). I get a bunch of errors. Now this
seems to work fine if I just need text returned, but am having trouble with
the image.
Function GetLogo(strOfficeLocation As String, strClientID As String) As
ADODB.Stream
Dim cmd1 As ADODB.Command, rs As ADODB.Recordset
GetLogo.Type = adTypeBinary
GetLogo.Open
Set cmd1 = New ADODB.Command
cmd1.ActiveConnection = MakeConnectionString
cmd1.CommandText = "dbo.GetLogo"
cmd1.CommandType = adCmdStoredProc
cmd1.CommandTimeout = lngTimeOut
cmd1.Parameters.Refresh
cmd1.Parameters(1).Value = strOfficeLocation
cmd1.Parameters(2).Value = strClientID
Set rs = cmd1.Execute()
'Collect the data
GetLogo.Write rs.Fields("Logo").Value
Set rs = Nothing
End Function
various reports. Depending on the options the user selects different
logos may print on the report.
My problem. The data for the report comes from a stored procedure. There
are many detail lines and I really do not want to include that image with
each row in the query so I would like to be able to access it separately
since it is only needed once. When I attempt to do this I end up with
errors or nothing displayed.
My question..... Ho can I manually access an image in the sql database and
display it on a report?
I tried something like...... The control source for the object frame
would be =GetLogo(value1,value2). I get a bunch of errors. Now this
seems to work fine if I just need text returned, but am having trouble with
the image.
Function GetLogo(strOfficeLocation As String, strClientID As String) As
ADODB.Stream
Dim cmd1 As ADODB.Command, rs As ADODB.Recordset
GetLogo.Type = adTypeBinary
GetLogo.Open
Set cmd1 = New ADODB.Command
cmd1.ActiveConnection = MakeConnectionString
cmd1.CommandText = "dbo.GetLogo"
cmd1.CommandType = adCmdStoredProc
cmd1.CommandTimeout = lngTimeOut
cmd1.Parameters.Refresh
cmd1.Parameters(1).Value = strOfficeLocation
cmd1.Parameters(2).Value = strClientID
Set rs = cmd1.Execute()
'Collect the data
GetLogo.Write rs.Fields("Logo").Value
Set rs = Nothing
End Function