Solved

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

Posted on 2001-09-13
11
462 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
ID: 6478737
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
ID: 6478782
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
ID: 6478802
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
Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

 

Author Comment

by:sheslop
ID: 6481383
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
ID: 6481435
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
 

Author Comment

by:sheslop
ID: 6481448
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
ID: 6481451
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
ID: 6481452
And also, your stored procedure code....
0
 

Author Comment

by:sheslop
ID: 6481470
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
ID: 6481490
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
ID: 7004949
again, just doing some cleaning up. you were very helpful valli_an
0

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

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.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Article by: Martin
Here are a few simple, working, games that you can use as-is or as the basis for your own games. Tic-Tac-Toe This is one of the simplest of all games.   The game allows for a choice of who goes first and keeps track of the number of wins for…
Since upgrading to Office 2013 or higher installing the Smart Indenter addin will fail. This article will explain how to install it so it will work regardless of the Office version installed.
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…

840 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