Solved

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

Posted on 2001-09-13
11
463 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

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

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

There are many ways to remove duplicate entries in an SQL or Access database. Most make you temporarily insert an ID field, make a temp table and copy data back and forth, and/or are slow. Here is an easy way in VB6 using ADO to remove duplicate row…
I’ve seen a number of people looking for examples of how to access web services from VB6.  I’ve been using a test harness I built in VB6 (using many resources I found online) that I use for small projects to work out how to communicate with web serv…
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…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

749 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