Passing Date Parameter to Sproc From VB6 via Crystal Reports

  • mrpolecat (10/22/2007)


    I don't know about CR but I would suggest starting a new thread for the question so people who do can answer it. You may also want to post it under a topic like programming or reporting so you get the right people looking at it.

    I have a few stored procedures as datasources for some of my Crystal Reports. All of them have parameters which I pass from VB6 to CR. I am having trouble passing date parameters as the usual format is not accepted by the sproc.

    Any tips / leads?


    Regards,

    goodguy

    Experience is a bad teacher whose exams precede its lessons

  • Why not use the and and only unambigous, language and datesetting independent format we have?

    'SSYYMMDD'

    ..should work with any SQL Server anywhere in the world.

    /Kenneth

  • Kenneth Wilhelmsson (10/23/2007)


    Why not use the and and only unambigous, language and datesetting independent format we have?

    'SSYYMMDD'

    ..should work with any SQL Server anywhere in the world.

    /Kenneth

    I tried all possible date formats via the ParameterFields(0) property in VB, the report just won't recognise any one of them.

    I've temporarily bypassed the problem by passing the parameters as strings and converting them to dates in my sproc.

    Any help will still be welcome.


    Regards,

    goodguy

    Experience is a bad teacher whose exams precede its lessons

  • VAIYDEYANATHAN.V.S (10/23/2007)


    try this link with the samples.

    http://www.vbmysql.com/articles/vb6-mysql/using-mysql-visual-basic-6-and-crystal-reports-9/%5B/quote%5D

    Thanks, I took a look at it; it is good but not of immediate use for me for this issue.


    Regards,

    goodguy

    Experience is a bad teacher whose exams precede its lessons

  • try something like....

    Dim crptApp As CRAXDRT.Application

    Dim crptParmDefs As CRAXDRT.ParameterFieldDefinitions

    Dim crptParmDef As CRAXDRT.ParameterFieldDefinition

    For Each crptParmDef In crptParmDefs

    With crptParmDef

    IF .ParameterFieldName = "ReportDateParameterName" then

    .SetCurrentValue dtDateVariable

    End If

    End With

    Next

  • This has worked for me. I use VB.Net but should not make a difference for VB 6.0

    Private Sub SetCrystalParameterDate(ByRef crParamFieldDefs As ParameterFieldDefinitions, _

    ByVal ParamName As String, ByVal ParamValue As DateTime)

    Dim crParameterFieldDefinition As ParameterFieldDefinition

    Dim crParameterValues As ParameterValues

    Dim crParameterDiscreteValue As ParameterDiscreteValue

    crParameterFieldDefinition = crParamFieldDefs.Item(ParamName)

    crParameterValues = crParameterFieldDefinition.CurrentValues

    crParameterValues.Clear()

    crParameterDiscreteValue = New ParameterDiscreteValue

    crParameterDiscreteValue.Value = ParamValue

    crParameterValues.Add(crParameterDiscreteValue)

    crParameterFieldDefinition.ApplyCurrentValues(crParameterValues)

    End Sub

    ''Then call the Proc.

    SetCrystalParameterDate(crParameterFieldDefinitions, "CrystalParameterName", dteToPassToReport)

Viewing 7 posts - 1 through 6 (of 6 total)

You must be logged in to reply to this topic. Login to reply