Hi,
I'm having problemes printing with Crystal Reports using VB.NET.Whenever I try printing on the local printer, when I don'tspecify a PrinterName, everything works fine. However, when Ichange the PrinterName, it always gives me the same error"Object reference not set to an instance of an object". I'vetried looking on the CR website but the only fix they give isfor Windows 98/ME and I'm running Windows 2000. I know thatCrystal Reports needs the complete and exact printer name.
Here's my code :
Dim rptDemande As RapportDemande
rptDemande = New RapportDemande
Dim ds As New DataSet
Dim daRapportCrystal As New SqlDataAdapter
daRapportCrystal.SelectCommand = New SqlCommand
daRapportCrystal.SelectCommand.CommandText ="procRapportDemande"
daRapportCrystal.SelectCommand.CommandType =CommandType.StoredProcedure
daRapportCrystal.SelectCommand.Connection =SqlConnection1
daRapportCrystal.SelectCommand.Parameters.Clear()
daRapportCrystal.SelectCommand.Parameters.Add("@No ",intNoCommande)
Try
daRapportCrystal.Fill(ds, "procRapportDemande")
Catch ex As Exception
MessageBox.Show(ex.Message)
End Try
rptDemande.Load()
rptDemande.SetDataSource(ds)
rptDemande.PrintOptions.PrinterName =ConfigurationSettings.AppSettings("printerApprovi sionnement")
rptDemande.PrintToPrinter(1, False, 0, 0)
rptDemande.Close()
whereConfigurationSettings.AppSettings("printerApp rovisionnement") is
<add key="printerApprovisionnement"value="\\bl_proxy1\b lmagi3" />
Thank you very much
--------------------------------
From: Anne-Marie Buki
-----------------------
Posted by a user from .NET 247 (http://www.dotnet247.com/)
<Id>DOkQaYtpWkSP+B4fRCuS/Q==</Id>