Crystal Reports XI With Visual Basic 6.0
' Add Form And rename to FrmRepView
' Add Code to Module
VB Code:
Sub ReporView(SQLsentence As String, ViewName As String, ReportName As String)
On Error Resume Next
Dim CN As New ADODB.Connection
Dim rss As New Recordset
Dim appw As New CRAXDDRT.Application
Dim rpt As New CRAXDDRT.Report
Dim tbl As CRAXDDRT.DatabaseTable
Dim db As New ADODB.Connection
CN.Execute "Drop View " & ViewName
CN.Execute "Create View " & ViewName & " as " & SQLsentence
x = App.Path & "\" & ReportName & ".rpt"
appw.LogOnServer "crdb_odbc.dll", "GRS", "GRS", "sa", "asd123"
Set rpt = appw.OpenReport(x)
rpt.Database.LogOnServer "crdb_odbc.dll", "GRS", "GRS", "sa", "asd123"
FrmRepView.show
FrmRepView.CrystalActiveXReportViewer1.Refresh
FrmRepView.CrystalActiveXReportViewer1.ReportSource = rpt
FrmRepView.CrystalActiveXReportViewer1.ViewReport
' appw.LogOnServer "crdb_odbc.dll", "GRS", "GRS", "sa", "asd123"
'DSN=grs;USER ID=sa;pwd=asdsuez;
End Sub
thes Code Work With Me
But
I Use Sql Server 2000
The problem Is When I Change Database Name
And Cang DSN To New Database
The Report Not View result
And Gev Me Error Logon failure
If Eny own Now The problem Help me please !