Monday, July 27, 2015

How to use the PrinterSetup Dialog Box From VB6 works with Crystal Reports


Printing the report through the Report Viewer and displaying the 'Print' dialog box====
Dim Report As New CrystalReport1

Private Sub Form_Load()
    'Set the report o the Report Viewer and display the report
    'with a zoom level of 100%

    CRViewer1.ReportSource = Report
    CRViewer1.ViewReport
    CRViewer1.Zoom 100
End Sub

'This event fires when the ''Print'' button in the Report Viewer is clicked
Private Sub CRViewer1_PrintButtonClicked(UseDefault As Boolean)
     'Create an instance of the Printer Setup dialog box
     'Set the handle of the Printer Setup dialog box to the form

     Report.PrinterSetup Form1.hWnd
     'Select Paper Size
     Report.PaperSize = crPaperA5

    'The ''Print'' dialog box will appear by default
    The ''Print'' dialog box needs to be displayed if you want the user
    'to set start page and stop page, the number of copies, and collate

End Sub

Wednesday, July 8, 2015

SQL SERVER – Fix Error 7202 Could not find server in sys.servers. Verify that the correct server name was specified

The other day I received following error when I tried to restore a database from one server to another server.
Msg 7202, Level 11, State 2, Line 1
Could not find server ‘MyLinkedServer’ in sys.servers. Verify that the correct server name was specified.
Well, this is quite a popular error one receive when they attempt to restore database containing references of the linked server. The solution is to create a link server and restore database. Here is the quick script which can fix your error.
EXEC sp_addlinkedserver @server='MyLinkedServer'
EXEC sp_addlinkedsrvlogin 'MyLinkedServer', 'false', NULL, 'MyUserName', 'MyPassword'