Here is the sub I use: (I connect to the db change were required)

vb.net Code:
  1. Public Sub outputToPrinter(ByVal mRepName As String, ByVal mstrW As String, Optional ByVal strPars As String = "")
  2.         Dim ConInfo As New CrystalDecisions.Shared.TableLogOnInfo
  3.         Dim paraValue As New CrystalDecisions.Shared.ParameterDiscreteValue
  4.         Dim currValue As New CrystalDecisions.Shared.ParameterValues
  5.         'Sub report object of crystal report.
  6.         Dim mySubReportObject As CrystalDecisions.CrystalReports.Engine.SubreportObject
  7.         'Sub report document of crystal report.
  8.         Dim mySubRepDoc As New CrystalDecisions.CrystalReports.Engine.ReportDocument
  9.         Dim i, x, z As Integer 'Some Counters
  10.         Dim mRep As New CrystalDecisions.CrystalReports.Engine.ReportDocument
  11.  
  12.         Try
  13.             ' Load the report
  14.             'Need to add the Report dll yet nothing works
  15.             Dim rep As New RSMReports.clsReports(mRepName)
  16.             mRep = rep.returnRep()
  17.             mRep.RecordSelectionFormula = mstrW
  18.  
  19.             ConInfo.ConnectionInfo.UserID = "UserName"
  20.             ConInfo.ConnectionInfo.Password = "Password"
  21.             ConInfo.ConnectionInfo.ServerName = mdlGeneral.serverName
  22.             ConInfo.ConnectionInfo.DatabaseName = mdlGeneral.dbName
  23.  
  24.             For i = 0 To mRep.Database.Tables.Count() - 1
  25.                 mRep.Database.Tables(i).ApplyLogOnInfo(ConInfo)
  26.             Next i
  27.  
  28.             'Check for Subreprots
  29.             For i = 0 To mRep.ReportDefinition.Sections.Count - 1
  30.                 For x = 0 To mRep.ReportDefinition.Sections(i).ReportObjects.Count - 1
  31.                     With mRep.ReportDefinition.Sections(i)
  32.                         If .ReportObjects(x).Kind = CrystalDecisions.Shared.ReportObjectKind.SubreportObject Then
  33.                             mySubReportObject = CType(.ReportObjects(x), CrystalDecisions.CrystalReports.Engine.SubreportObject)
  34.                             mySubRepDoc = mySubReportObject.OpenSubreport(mySubReportObject.SubreportName)
  35.                             For z = 0 To mySubRepDoc.Database.Tables.Count - 1
  36.                                 mySubRepDoc.Database.Tables(z).ApplyLogOnInfo(ConInfo)
  37.                             Next z
  38.                         End If
  39.                     End With
  40.                 Next x
  41.             Next i
  42.             'Parameter Fields
  43.             If strPars.Trim() <> String.Empty Then
  44.                 Dim arPars As String() = strPars.Split("~")
  45.                 Dim strVal As String()
  46.                 For xx As Integer = 0 To arPars.GetUpperBound(0)
  47.                     strVal = arPars(xx).Split("=")
  48.                     paraValue.Value = strVal(1)
  49.                     currValue = mRep.DataDefinition.ParameterFields(strVal(0)).CurrentValues
  50.                     currValue.Add(paraValue)
  51.                     mRep.DataDefinition.ParameterFields(xx).ApplyCurrentValues(currValue)
  52.                 Next
  53.             End If
  54.             mRep.PrintToPrinter(1, False, 0, 0)
  55.         Catch crExp As CrystalDecisions.CrystalReports.Engine.LoadSaveReportException
  56.             MessageBox.Show("Error printing Report " & mRepName & System.Environment.NewLine & _
  57.                 "The error number is: " & Err.Number.ToString() & System.Environment.NewLine & _
  58.                 "The error Message is: " & System.Environment.NewLine & crExp.Message.Trim(), "Print Error", MessageBoxButtons.OK, MessageBoxIcon.Error)
  59.         Catch ex As Exception
  60.             MessageBox.Show("Error printing Report " & mRepName & System.Environment.NewLine & _
  61.                             "The error number is: " & Err.Number.ToString() & System.Environment.NewLine & _
  62.                             "The error Message is: " & System.Environment.NewLine & ex.Message.Trim(), "Print Error", MessageBoxButtons.OK, MessageBoxIcon.Error)
  63.         Finally
  64.             mRep.Dispose()
  65.         End Try
  66.     End Sub