Click here to Skip to main content
15,889,820 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
I am using VS 2008. I created a Crystal Report to print an Invoice in my program.
I wrote code for two different things in Which:

1) Code for printing simple data from a single table.
2) Code for fetching data from two different tables.

There is an error: Log On parameter Fail
How can I solve it?

Here my code is:

VB
Call openconnection()
               str = "SELECT * from Stock_Management where CaseId=" & temp_No & ""
               da = New SqlDataAdapter(str, cn)
               ds.Clear()

               da.Fill(ds, "Stock_Management")
               'MsgBox(ds.Tables("New_Case_Id_Master").Rows.Count)
               cn.Close()

               Dim objRpt1 As New CrystalReport_for_PartsConsumed

               objRpt1.SetDataSource(ds.Tables("Stock_Management"))
               CrystalReportViewer1.ReportSource = objRpt1
               CrystalReportViewer1.PrintReport()
               CrystalReportViewer1.Refresh()

               Dim logOnInfo As New TableLogOnInfo
               CrystalReportViewer1.Refresh()
               cn = New SqlConnection("Data Source=NIRAV-PC\SQLEXPRESS;Initial Catalog=company_database;User ID=sa;Password=nirav")
               cn.Open()
               str = "  SELECT *  FROM Asset_Service_Master,Part_Estimation_Master WHERE  Asset_Service_Master.CaseId=Part_Estimation_Master.CaseId  AND Part_Estimation_Master.CaseId=" & temp_No & ""
               da = New SqlDataAdapter(str, cn)
               ds1.Clear()
               da.Fill(ds1)

               'MsgBox(ds.Tables("New_Case_Id_Master").Rows.Count)
               cn.Close()

               logOnInfo.ConnectionInfo.DatabaseName = "company_database"
               logOnInfo.ConnectionInfo.UserID = "sa"
               logOnInfo.ConnectionInfo.Password = "nirav"
               Dim objRpt As New CrystalReport_For_Billing

               ' Apply connection info. to every table in the report
               For Each tbl As Table In objRpt.Database.Tables
                   tbl.ApplyLogOnInfo(logOnInfo)
               Next

               objRpt.SetDataSource(ds1.Tables(0))
               CrystalReportViewer1.ReportSource = objRpt
               CrystalReportViewer1.PrintReport()
               CrystalReportViewer1.PrintReport()
               CrystalReportViewer1.Refresh()
Posted
Updated 1-Jan-11 2:01am
v2

1 solution

You forgot to apply the database server value in logoninfo details at runtime(Like you have applied database, userid,password details at runtime).
So add the below line in logininfo section
VB
logOnInfo.ConnectionInfo.ServerName = "ServerName"

For your Information
VB.NET Crystal Reports Load Dynamically [^]
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900