ChrisHiggins
Programmer
I am converting a project from VB6 to VB.net and I am having problems with the crystal reports. The code is as follows:-
'Print the transfer report
Dim CPProperty As CRAXDDRT.ConnectionProperty
Dim DBTable As CRAXDDRT.DatabaseTable
Dim Report As New TransferReport
DBTable = Report.Database.Tables(1) '<--- This is the line that it is erroring.
'Connect to the sql server
CPProperty = DBTable.ConnectionProperties("Data Source")
CPProperty.Value = stSqlServer
'Set the database user name
CPProperty = DBTable.ConnectionProperties("User ID")
CPProperty.Value = stSqlSignon
'Set the database password
CPProperty = DBTable.ConnectionProperties("Password")
CPProperty.Value = stSqlPassword
'Connect to the required database
CPProperty = DBTable.ConnectionProperties("Initial Catalog")
CPProperty.Value = "S_P_Reporting"
'Connect to the required table or view
DBTable.Location = "Nominal_Reporting_Priarch"
'Print the report
'Report.PrintOut(False)
Report.PrintToPrinter(1, False, 1, 999)
The error I get is "system.InvalidCastException".
Can anybody tell me what I am doing wrong?
Thanks
Chris
'Print the transfer report
Dim CPProperty As CRAXDDRT.ConnectionProperty
Dim DBTable As CRAXDDRT.DatabaseTable
Dim Report As New TransferReport
DBTable = Report.Database.Tables(1) '<--- This is the line that it is erroring.
'Connect to the sql server
CPProperty = DBTable.ConnectionProperties("Data Source")
CPProperty.Value = stSqlServer
'Set the database user name
CPProperty = DBTable.ConnectionProperties("User ID")
CPProperty.Value = stSqlSignon
'Set the database password
CPProperty = DBTable.ConnectionProperties("Password")
CPProperty.Value = stSqlPassword
'Connect to the required database
CPProperty = DBTable.ConnectionProperties("Initial Catalog")
CPProperty.Value = "S_P_Reporting"
'Connect to the required table or view
DBTable.Location = "Nominal_Reporting_Priarch"
'Print the report
'Report.PrintOut(False)
Report.PrintToPrinter(1, False, 1, 999)
The error I get is "system.InvalidCastException".
Can anybody tell me what I am doing wrong?
Thanks
Chris