Solved

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

Posted on 2001-09-13
11
459 Views
Last Modified: 2007-12-19
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
0
Comment
Question by:sheslop
  • 6
  • 4
11 Comments
 
LVL 15

Expert Comment

by:lyonst
Comment Utility
Not sure if this will help you ?

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

Cheers,

T.
0
 
LVL 9

Expert Comment

by:Valliappan AN
Comment Utility
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
 
LVL 9

Expert Comment

by:Valliappan AN
Comment Utility
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
 

Author Comment

by:sheslop
Comment Utility
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
 

Author Comment

by:sheslop
Comment Utility
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
How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

 

Author Comment

by:sheslop
Comment Utility
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
 
LVL 9

Expert Comment

by:Valliappan AN
Comment Utility
Can you paste the new code, that you tried, and did not work?
0
 
LVL 9

Accepted Solution

by:
Valliappan AN earned 200 total points
Comment Utility
And also, your stored procedure code....
0
 

Author Comment

by:sheslop
Comment Utility
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
 

Author Comment

by:sheslop
Comment Utility
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
 

Author Comment

by:sheslop
Comment Utility
again, just doing some cleaning up. you were very helpful valli_an
0

Featured Post

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Suggested Solutions

Introduction While answering a recent question about filtering a custom class collection, I realized that this could be accomplished with very little code by using the ScriptControl (SC) library.  This article will introduce you to the SC library a…
When trying to find the cause of a problem in VBA or VB6 it's often valuable to know what procedures were executed prior to the error. You can use the Call Stack for that but it is often inadequate because it may show procedures you aren't intereste…
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…

772 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

15 Experts available now in Live!

Get 1:1 Help Now