I'm trying to run a report in VB 6 and having a heck of a time. I think my major problem right now is that it doesn't know where I'm trying to connect to and with which credentials. I've looked thru k.babu's sticky thread, but haven't found a solution.
Here is the code I have right now:
Private Sub Form_Load()
Screen.MousePointer = vbHourglass
CRViewer1.ReportSource = Report
Screen.MousePointer = vbDefault
With Report
.ParameterFields(1).ClearCurrentValueAndRange
.ParameterFields(1).AddCurrentValue "KL"
.Database.LogOnServer "p2ssql.dll", "tsg2170", "tableName", "username", "password"
End With
CRViewer1.ViewReport
End Sub
I don't have a clue what to do. BTW, this is my first attempt at anything with crystal in VB.
The error I'm getting is:
Login Failed.
Details: ADO error code: 0x80040e4d
Source: Microsoft OLE DB Provider for SQL Server
Description: Login failed for user 'username'.
SQL State: 42000
Native Error: 18456
I know the username/password are correct.Here is my solution
Private Sub Form_Load()
Dim CRXReport As CRAXDDRT.Report
Dim CRXDb As CRAXDDRT.Database
Dim CRXTbl As CRAXDDRT.DatabaseTable
Dim init As Integer
Set CRXReport = Report
Set CRXDb = CRXReport.Database
CRXReport.DiscardSavedData
init = 1
Do Until init = CRXReport.Database.Tables.Count + 1
CRXReport.Database.Tables.Item(init).SetLogOnInfo "tsg2107", "sedonaMM", "username", "password"
init = init + 1
Loop
With frmMain
.Show
CRXReport.ParameterFields(1).AddCurrentValue "LH"
With CRXReport
.ExportOptions.DestinationType = crEDTDiskFile
.ExportOptions.DiskFileName = "C:\LHReport.pdf"
.ExportOptions.FormatType = crEFTPortableDocFormat
End With
.CRViewer1.ReportSource = CRXReport
CRXReport.Export False
End With
Set CRXReport = Nothing
End Sub
No comments:
Post a Comment