Skip to Content
author's profile photo Former Member
Former Member

database login always prompt

this is my code which works perfectly fine,but when i always click the print button,database login always prompt:

Dim cryRpt As New ReportDocument

Dim crParameterFieldDefinitions As ParameterFieldDefinitions

Dim crParameterFieldDefinition As ParameterFieldDefinition

Dim crParameterValues As New ParameterValues

Dim crParameterDiscreteValue As New ParameterDiscreteValue

Dim conn As New SqlConnection(ConnectString())

Dim cmd As New SqlCommand

Dim mydatatable As New DataTable

cryRpt.Load("C:\Users\Frontliner0102\Desktop\newRSVSYSTEM\ReservationSys\ReservationSys\ReservationSys\Reports\orderrpt.rpt")

If conn.State = ConnectionState.Closed Then

conn.Open()

End If

cmd.Connection = conn

cmd.CommandText = "select folioid from foodordertbl where folioid=" + folioid

Dim lad As SqlDataReader = cmd.ExecuteReader()

mydatatable.Load(lad)

DataGridView1.DataSource = mydatatable

lad.Close()

crParameterDiscreteValue.Value = folioid

crParameterFieldDefinitions = cryRpt.DataDefinition.ParameterFields

crParameterFieldDefinition = crParameterFieldDefinitions.Item("folioid")

crParameterValues = crParameterFieldDefinition.CurrentValues

crParameterValues.Clear()

crParameterValues.Add(crParameterDiscreteValue)

crParameterFieldDefinition.ApplyCurrentValues(crParameterValues)

CrystalReportViewer1.ReportSource = cryRpt

CrystalReportViewer1.Refresh()

Add a comment
10|10000 characters needed characters exceeded

Related questions

1 Answer

  • Best Answer
    Posted on May 24, 2013 at 02:55 PM

    I don't see where you are telling the report what to connect to? I see you creating this:

    DataGridView1.DataSource = mydatatable

    But how does the CR engine know to use it?

    - Ludek

    Senior Support Engineer AGS Product Support, Global Support Center Canada

    Follow us on Twitter

    Got Enhancement ideas? Try the SAP Idea Place

    Share Your Knowledge in SCN Topic Spaces

    Add a comment
    10|10000 characters needed characters exceeded

Before answering

You should only submit an answer when you are proposing a solution to the poster's problem. If you want the poster to clarify the question or provide more information, please leave a comment instead, requesting additional details. When answering, please include specifics, such as step-by-step instructions, context for the solution, and links to useful resources. Also, please make sure that you answer complies with our Rules of Engagement.
You must be Logged in to submit an answer.

Up to 10 attachments (including images) can be used with a maximum of 1.0 MB each and 10.5 MB total.