CRYSTAL REPORT - CONEXAO VIA CODIGO

GUILHERMEMFA 23/07/2010 14:26:03
#348273
Boa tarde pessoal,
vou tentar explicar, se não entenderem eu tento novamente

Estou trabalhando com o VB6, com MSSQL 7.0 e Crystal Report XI.
Tenho seguintes Referências e Componentes ativos no VB6 para o Crystal Report:
Referências
- Crystal ActiveX Report Viewer Export Library 11.5
- Crystal ActiveX Report Viewer Library 11.5
- Crystal ActiveX Report Viewer Web Report Source Library 11.5
- Crystal Report ActiveX Designer Run Time Library 11.5
- Crystal Report ActiveX Designer Design and Runtime Library 11.5
Componetes
Na Guia - Controls
- Crystal ActiveX Report Viewer Library 11.5
Na Guia - Designers
- Crystal Report 11.5

Os relatórios que eu criei no VB6 estão na extensão DSR.

Agora o Problema:
Nos relatorios que fiz no Crystal eu informo os dados do BANCO que estou trabalhando:
Nome do banco, nome do usuário, senha, e a query/sql que eu vou precisar no meu relatório.

Dúvida:
Como eu faria isso via código no VB6?

Grato
RFTD 23/07/2010 15:10:21
#348277
Resposta escolhida
Cara vc precisa criar uma form e nela colocar o componente viewer.
no load vc coloca um codigo assim
  Public Sub CarregarRelatorio()
On Error GoTo tratar

[ô]Unload Me
Dim rs As New ADODB.Recordset [ô]HOLDS ALL DATA RETURNED FROM QUERY

rs.CursorLocation = adUseClient
rs.Open [Ô]Sua Sql de Filtro[Ô], MyDatabase, adOpenForwardOnly, adLockReadOnly, adCmdText
Set rs.ActiveConnection = Nothing

If rs.EOF Then
MsgBox [Ô]Não há registros![Ô], vbInformation
Unload Me
Exit Sub
End If


Dim report As CRAXDRT.report [ô]HOLDS REPORT

Set report = Nome do Seu report
report.DiscardSavedData [ô]CLEARS REPORT SO WE WORK FROM RECORDSET
report.Database.SetDataSource rs [ô]LINK REPORT TO RECORDSET

Me.Show

[ô]CRViewer.DisplayBorder = False [ô]MAKES REPORT FILL ENTIRE FORM
[ô]CRViewer.DisplayTabs = False [ô]THIS REPORT DOES NOT DRILL DOWN, NOT NEEDED
[ô]CRViewer.EnableDrilldown = False [ô]REPORT DOES NOT SUPPORT DRILL-DOWN
[ô]CRViewer.EnableRefreshButton = False [ô]ADO RECORDSET WILL NOT CHANGE, NOT NEEDED
[ô]CRViewer.EnableExportButton = True [ô]EXPORTAR RELATORIO

CRViewer.ReportSource = report [ô]LINK VIEWER TO REPORT
CRViewer.ViewReport [ô]SHOW REPORT

Do While CRViewer.IsBusy [ô]ZOOM METHOD DOES NOT WORK WHILE
DoEvents [ô]REPORT IS LOADING, SO WE MUST PAUSE
Loop [ô]WHILE REPORT LOADS.

CRViewer.Top = 0 [ô]WHEN FORM IS RESIZED
CRViewer.Left = 0
CRViewer.Height = ScaleHeight
CRViewer.Width = ScaleWidth

rs.Close
Set rs = Nothing
Set crystal = Nothing
Set report = Nothing

limparVariaveis
Exit Sub
tratar:
MsgBox Err.Description

End Sub


fazendo isso deve funcionar de boa.
GUILHERMEMFA 23/07/2010 16:55:13
#348289
RFTD

Acho que é isso mesmo, to testando aqui
Tópico encerrado , respostas não são mais permitidas