Monday, March 19, 2012

Logon Failed

Hi!

Please check out my code. I get this error when I 'CRViewer.ViewReport' is called.

Logon failed.
Details: ADO Error Code: 0x80030020
Source: MS OLE DB Service Components
Description: A share violation has occured

The code is pretty simple and basic. Is there anything missing or something I didn't declare?

Thanks a lot!

--------------------

Dim crxApp As New CRAXDRT.Application
Dim crxRep As CRAXDRT.Report
Dim crxDBTable As CRAXDRT.DatabaseTable
Dim crxDB As CRAXDRT.Database
Dim crxConn As CRAXDRT.ConnectionProperty

On Error GoTo ERROR_HANDLER

DoEvents
Screen.MousePointer = vbHourglass

Do
DoEvents

If CBox.GetPrinterJobs(TReport.DeviceName) <= 2 Then
Exit Do
End If
Loop

Select Case UCase(TReport.reportName)
Case "PASTDUE_SCHEDULE"
strFilename = "PDOSchedule"

Case "PASTDUE_CURRENT"
strFilename = "PDOCurrent"

Case "PASTDUE_30DAYS"
strFilename = "PDO30Days"

Case "PASTDUE_ACTIVE"
strFilename = "PDOActive"

Case "PASTDUE_SUSPENDED"
strFilename = "PDOSuspended"

Case "PASTDUE_CANCELLED"
strFilename = "PDOCancelled"

Case "PASTDUE_ABC"
strFilename = "PDOABCEmployees"

End Select

' Open crystal report printjob and get number of parameters
strFilename = UCase(App.Path & "\Reports\" & strFilename & ".rpt")
strMessage = TPastDue.Message

' Open the report
Set crxRep = crxApp.OpenReport(strFilename)

' Set database location
Set crxDBTable = crxRep.Database.Tables(1)
crxDBTable.Location = CBox.IniFileRead("Database", "Name")

' Pass parameters to report
With crxRep.ParameterFields
For i = 1 To .Count
For j = 0 To .Count - 1
If Trim(UCase(.Item(i).parameterFieldName)) = Trim(UCase(TReport.Parameters(j, 0))) Then
.Item(i).AddCurrentValue TReport.Parameters(j, 1)
Exit For
End If
Next
Next
End With

' Set printer settings
With TReport
crxRep.SelectPrinter .DriverName, .DeviceName, .Port
End With

' Set selection formula
If TReport.Filter <> "" Then
crxRep.RecordSelectionFormula = TReport.Filter
End If

Screen.MousePointer = vbDefault

With frmReportPreview.CRViewer
.ReportSource = crxRep
.ViewReport
End WithDear Questioner, Please use logon properties.

Dim Application As New CRAXDRT.Application

Dim report As CRAXDRT.report

Dim tbl As CRAXDRT.DatabaseTable
Set report = Application.OpenReport("E:\NAD\rptItemSearch.rpt")

Set tbl = report.Database.Tables(1)

tbl.ConnectionProperties("Data Source") = "SQLSERVER"
tbl.ConnectionProperties("Initial Catalog") = "Hilbro"
tbl.ConnectionProperties("User ID") = "Wajid"
tbl.ConnectionProperties("Password") = "WSBis#1"

frmItemReport.CRViewer.ReportSource = report

frmItemReport.CRViewer.ViewReport

frmItemReport.Show

I hope this will help.

No comments:

Post a Comment