worldapart
Programmer
I am working on VB6 for crystal reports 10 Develop Edition , the database is MYSQL. i need three tables to create a report .it works fine in local LAN (any of the computers,windows),but when connecting by remote access through VPN ,an weird error comes out :Logon Failed Details:01000:[Microsoft][ODBC SQL Sever Driver][DBNETLIB]connectionopen(connect()).
but if i use only one table to create it no matter in LAN or VPN works perfectly .after googling.knowing that each table need User ID ,Password,DSN to login .but it didn't work for me .could it be possible that the SQL string is not so appropriate ?
anyone who can give me some hints or codes i would be greatly appreciate. thanks a lot in advance
here is my code:
Option Explicit
Const CONSTR = "Provider=SQLOLEDB;data Source=***;Initial Catalog=northwind; " & _
"User Id=***;Password=***"
Dim strSQL As String
Dim rs As New ADODB.Recordset
Dim conn As New ADODB.Connection
Dim crystal As CRAXDRT.Application 'LOADS REPORT FROM FILE
Dim report As CRAXDRT.report 'HOLDS REPORT
Dim CRXDATABASETABLE As CRAXDRT.DatabaseTable
Private Sub Form_Load()
'THIS CODE IS USED TO DISPLAY A CRYSTAL REPORTS 9 REPORT USING
'DATA PULLED FROM A MYSQL DATABASE USING ADO AND VISUAL BASIC 6
'YOU NEED REFERENCES TO: Microsoft ActiveX Data Objects 2.7 Library
' Crystal Reports 9 ActiveX Designer Run Time Library
'YOU NEED THE COMPONENT: Crystal Reports Viewer Control 9
'ADD THE CRVIEWER91 COMPONENT TO YOUR FORM AND NAME IT CRViewer.
CRViewer.EnableExportButton = True
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
Dim strsql1 As String
Me.WindowState = 2
strsql1 = "select customer.country,customer.name,supplier.country,supplier.name,order.id,order.product from customer,supplier,order where customer.id='" & Trim(form.id1.Text) & "' and supplier.id='" & Trim(form.id2.Text) & "' and order.id='" & Trim(form.id3.Text) & "'"
If conn.State = adStateClosed Then _
conn.Open CONSTR
If rs.State = adStateOpen Then rs.Close
Set rs.ActiveConnection = conn
rs.Open strsql1, conn, adOpenKeyset, adLockOptimistic
Set crystal = New CRAXDRT.Application 'MANAGES REPORTS
Set report = crystal.OpenReport(App.Path & "\order Report.rpt") 'OPEN OUR REPORT
For Each CRXDATABASETABLE In report.Database.Tables
CRXDATABASETABLE.ConnectionProperties.DeleteAll
CRXDATABASETABLE.ConnectionProperties.Add "DSN", "***"
CRXDATABASETABLE.ConnectionProperties.Add "user id", "***"
CRXDATABASETABLE.ConnectionProperties.Add "password", "***"
Next CRXDATABASETABLE
report.DiscardSavedData 'CLEARS REPORT SO WE WORK FROM RECORDSET
report.Database.SetDataSource rs 'LINK REPORT TO RECORDSET
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.Zoom 100
rs.Close 'ALL BELOW HERE IS CLEANUP
conn.Close
Set conn = Nothing
Set crystal = Nothing
Set report = Nothing
End Sub
Private Sub Form_Resize() 'MAKE SURE REPORT FILLS FORM
CRViewer.Top = 0 'WHEN FORM IS RESIZED
CRViewer.Left = 0
CRViewer.Height = ScaleHeight
CRViewer.Width = ScaleWidth
but if i use only one table to create it no matter in LAN or VPN works perfectly .after googling.knowing that each table need User ID ,Password,DSN to login .but it didn't work for me .could it be possible that the SQL string is not so appropriate ?
anyone who can give me some hints or codes i would be greatly appreciate. thanks a lot in advance
here is my code:
Option Explicit
Const CONSTR = "Provider=SQLOLEDB;data Source=***;Initial Catalog=northwind; " & _
"User Id=***;Password=***"
Dim strSQL As String
Dim rs As New ADODB.Recordset
Dim conn As New ADODB.Connection
Dim crystal As CRAXDRT.Application 'LOADS REPORT FROM FILE
Dim report As CRAXDRT.report 'HOLDS REPORT
Dim CRXDATABASETABLE As CRAXDRT.DatabaseTable
Private Sub Form_Load()
'THIS CODE IS USED TO DISPLAY A CRYSTAL REPORTS 9 REPORT USING
'DATA PULLED FROM A MYSQL DATABASE USING ADO AND VISUAL BASIC 6
'YOU NEED REFERENCES TO: Microsoft ActiveX Data Objects 2.7 Library
' Crystal Reports 9 ActiveX Designer Run Time Library
'YOU NEED THE COMPONENT: Crystal Reports Viewer Control 9
'ADD THE CRVIEWER91 COMPONENT TO YOUR FORM AND NAME IT CRViewer.
CRViewer.EnableExportButton = True
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
Dim strsql1 As String
Me.WindowState = 2
strsql1 = "select customer.country,customer.name,supplier.country,supplier.name,order.id,order.product from customer,supplier,order where customer.id='" & Trim(form.id1.Text) & "' and supplier.id='" & Trim(form.id2.Text) & "' and order.id='" & Trim(form.id3.Text) & "'"
If conn.State = adStateClosed Then _
conn.Open CONSTR
If rs.State = adStateOpen Then rs.Close
Set rs.ActiveConnection = conn
rs.Open strsql1, conn, adOpenKeyset, adLockOptimistic
Set crystal = New CRAXDRT.Application 'MANAGES REPORTS
Set report = crystal.OpenReport(App.Path & "\order Report.rpt") 'OPEN OUR REPORT
For Each CRXDATABASETABLE In report.Database.Tables
CRXDATABASETABLE.ConnectionProperties.DeleteAll
CRXDATABASETABLE.ConnectionProperties.Add "DSN", "***"
CRXDATABASETABLE.ConnectionProperties.Add "user id", "***"
CRXDATABASETABLE.ConnectionProperties.Add "password", "***"
Next CRXDATABASETABLE
report.DiscardSavedData 'CLEARS REPORT SO WE WORK FROM RECORDSET
report.Database.SetDataSource rs 'LINK REPORT TO RECORDSET
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.Zoom 100
rs.Close 'ALL BELOW HERE IS CLEANUP
conn.Close
Set conn = Nothing
Set crystal = Nothing
Set report = Nothing
End Sub
Private Sub Form_Resize() 'MAKE SURE REPORT FILLS FORM
CRViewer.Top = 0 'WHEN FORM IS RESIZED
CRViewer.Left = 0
CRViewer.Height = ScaleHeight
CRViewer.Width = ScaleWidth