printing crystal report from VB, using print engine API, passing paramters

im attempting to print a crystal report using the print engine API, the stored procedure requires 2 parameters of type character and length 3 and 4.

i always get error 538, bad structure size, can anyone help? the code is as follows

    'Set month parameter info
    MonthInfo.StructSize = 3
    MonthInfo.valueType = PE_VI_CH
    MonthInfo.viString = strMonth
   
    'Set year parameter info
    YearInfo.StructSize = 4
    YearInfo.valueType = PE_VI_CH
    YearInfo.viString = strYear
   
    'Set Month Parameter field
    Handle = PEAddParameterCurrentValue(job, "@Month" +   Chr$(0), "" + Chr$(0), MonthInfo)
   
    If Handle = 0 Then
        ErrorNum = PEGetErrorCode(Handle)
        MsgBox "Could not pass Month Parameter values,    ErrNum: " & ErrorNum
    Else
        MsgBox "Month Parameter passed successfully"
    End If
   
    'Set Year Parameter field
    Handle = PEAddParameterCurrentValue(job, "@Year" + Chr$(0), "" + Chr$(0), YearInfo)
   
    If Handle = 0 Then
        ErrorNum = PEGetErrorCode(Handle)
        MsgBox "Could not pass Year Parameter values, ErrNum: " & ErrorNum
    Else
        MsgBox "Year Parameter passed successfully"
    End If
sheslopAsked:
Who is Participating?
 
Valliappan ANConnect With a Mentor Senior Tech ConsultantCommented:
And also, your stored procedure code....
0
 
lyonstCommented:
Not sure if this will help you ?

http://www.apostate.com/programming/vb-crpe.html

Cheers,

T.
0
 
Valliappan ANSenior Tech ConsultantCommented:
Have a look at this:

http://support.crystaldecisions.com/kbase/c2003181.asp
(Passing a Stored Procedure Parameter at Runtime)

Also, my observation is:
>> PE_VI_CH

Is it not PE_VI_CHAR??

Hope it helps.
0
Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

 
Valliappan ANSenior Tech ConsultantCommented:
Also see if this helps:

http://support.crystaldecisions.com/kbase/c2000289.asp

(Working with SCR parameter fields using version 5 and 6 Print Engine (API) calls)
0
 
sheslopAuthor Commented:
valli_an,

it is CHAR, and i did declare the structure type using PE_VI_CHAR, but have since tried PE_VI_STRING and when i posted i reverted back to TYPE char for the post and typed in CH instead of CHAR after a paste.

anyhoo, ill now proceed to check the links.
0
 
sheslopAuthor Commented:
thanks guys but 2 of those links i had used before to no avail and the third didn't mention passing parameters to stored procedures.

anything else?
0
 
sheslopAuthor Commented:
thanks guys but 2 of those links i had used before to no avail and the third didn't mention passing parameters to stored procedures.

anything else?
0
 
Valliappan ANSenior Tech ConsultantCommented:
Can you paste the new code, that you tried, and did not work?
0
 
sheslopAuthor Commented:
tried a number of changes, including the following

MonthInfo.StructSize = 3
MonthInfo.valueType = PE_VI_CHAR
MonthInfo.viString = "APR"

gives me error:0, which is apparently no error

MonthInfo.StructSize = PE_SIZEOF_VALUE_INFO
MonthInfo.valueType = PE_VI_CHAR
MonthInfo.viString = "APR"

gives me error:561, bad value type.

MonthInfo.StructSize = PE_SIZEOF_VALUE_INFO
MonthInfo.valueType = PE_VI_STRING
MonthInfo.viString = "APR"

gives me error:538, bad structure size.

haven't altered any other code.

the stored procedure is


CREATE PROCEDURE spAluminaLevels (@month as CHAR(3), @year as CHAR(4)) AS

DECLARE @startmonth datetime
DECLARE @endmonth datetime

BEGIN

SELECT @endmonth = '1-' + @month + '-' + @year

SELECT @endmonth =   CONVERT(datetime,@endmonth)
SELECT @startmonth =  DATEADD(mm, -1, @endmonth)

SELECT
     DATENAME(dd, a.[Time]) + '-' + DATENAME(mm, a.[Time]) + '-' + DATENAME(yyyy, a.[Time]) AS [Time],
     DATENAME(dd, b.[Time]) + '-' + DATENAME(mm, b.[Time]) + '-' + DATENAME(yyyy, b.[Time]) AS Time_x,
     a.Silo1,
     b.Silo1 AS Silo1_x,
     a.Silo1 - b.Silo1 AS Silo1_d,
     a.Silo2,
     b.Silo2 AS Silo2_x,
     a.Silo2 - b.Silo2 AS Silo2_d,
     a.Silo3,
     b.Silo3 AS Silo3_x,
     a.Silo3 - b.Silo3 AS Silo3_d,
     a.Silo4,
     b.Silo4 AS Silo4_x,
     a.Silo4 - b.Silo4 AS Silo4_d,
     a.Silo5,
     b.Silo5 AS Silo5_x,
     a.Silo5 - b.Silo5 AS Silo5_d,
     a.Silo6,
     b.Silo6 AS Silo6_x,
     a.Silo6 - b.Silo6 AS Silo6_d,
     a.W1AlDay + a.W1FlSilo AS W1Silo,
     b.W1AlDay + b.W1FlSilo AS W1Silo_x,
     a.W1AlDay + a.W1FlSilo - b.W1AlDay - b.W1FlSilo AS W1Silo_d,
     a.E1AlDay + a.E1FlSilo AS E1Silo,
     b.E1AlDay + b.E1FlSilo AS E1Silo_x,
     a.E1AlDay + a.E1FlSilo - b.E1AlDay - b.E1FlSilo AS E1Silo_d,
     a.W2AlDay AS W2Silo,
     b.W2AlDay AS W2Silo_x,
     a.W2AlDay - b.W2AlDay AS W2Silo_d,
     a.E2AlDay AS E2Silo,
     b.E2AlDay AS E2Silo_x,
     a.E2AlDay - b.E2AlDay AS E2Silo_d,
     a.P12FlSilo + a.P12AlSilo AS P12Silo,
     b.P12FlSilo + b.P12AlSilo AS P12Silo_x,
     a.P12FlSilo + a.P12AlSilo - b.P12FlSilo - b.P12AlSilo AS P12Silo_d,
     a.W3AlDay AS W3Silo,
     b.W3AlDay AS W3Silo_x,
     a.W3AlDay - b.W3AlDay AS W3Silo_d,
     a.E3AlDay AS E3Silo,
     b.E3AlDay AS E3Silo_x,
     a.E3AlDay - b.E3AlDay AS E3Silo_d,
     a.BOFrSilo + a.BOChSilo AS BOSilo,
     b.BOFrSilo + b.BOChSilo AS BOSilo_x,
     a.BOFrSilo + a.BOChSilo - b.BOFrSilo - b.BOChSilo AS BOSilo_d
FROM
     dbo.AluminaLevels a INNER JOIN dbo.AluminaLevels b ON DATEPART(mm, DATEADD(mm, - 1, a.[Time])) = DATEPART(mm, b.[Time])
WHERE
     DATENAME(mm, a.[Time]) = DATENAME(mm, @endmonth) AND
     DATENAME(yyyy, a.[Time]) = DATENAME(yyyy, @endmonth)

END
   
   
0
 
sheslopAuthor Commented:
attempted to get parameter info using

Handle = PEGetNthParameterField(job, 2, ParamInfo)

and again i got an error, error:0 (which is apparently no error)
0
 
sheslopAuthor Commented:
again, just doing some cleaning up. you were very helpful valli_an
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.