MikeMcKeown
Programmer
Hi,
I have been working on the piece of code below in a DTS package. The two lines highlighted are causing problems. The 1st one I am getting an error with is saying that their is a type mismatch. In the table currentpractice is a varchar - am I declaring it incorrectly?
The second line says that there is a missing or out of date export dll.
Any ideas? I have this code working in normal visual basic.
Function Main()
Main = DTSTaskExecResult_Success
Dim Conn 'ADO Connection
Dim Comm 'ADO Command
Dim Rcdset 'ADO Recordset
Dim App
Dim report 'Crystal Report
Dim DB 'Crystal Database
Dim Tables 'Crystal DatabaseTables
Dim Table1 'Crystal DatabaseTable
Dim currentpractice
currentpractice = 2A
Dim final
Set Conn = CreateObject("ADODB.Connection")
Set Comm = CreateObject("ADODB.Command")
Set Rcdset = CreateObject("ADODB.Recordset")
Conn.Open "Provider=SQLOLEDB.1;Initial Catalog=E_Audit_Database;App=Crystal Export;Data Source=(local)", "**", "*****"
'Comm.ActiveConnection = Conn
final = "final_reports_last_generated"
Rcdset.Open final, Conn, adOpenStatic, , adCmdTable
While (NOT Rcdset.EOF )
Msgbox("in the While statement")
currentpractice = Rcdset.Fields.Item(0)
Msgbox(currentpractice)
Set App = CreateObject("CrystalRuntime.application.8.5") ' This is on a machine with Crystal 8.5
Set report = App.OpenReport("Z:\report1.rpt")
report.DiscardSavedData
Set DB = report.Database
Set Tables = DB.Tables
Set Table1 = Tables.Item(1)
report.ParameterFields.Item(1).AddCurrentValue currentpractice
report.ReadRecords
report.ExportOptions.DestinationType = crEDTDiskFile
report.ExportOptions.FormatType = crEFTWordForWindows
report.ExportOptions.DiskFileName = "C:\TEST\diditwork.rtf"
'report.Export False
Set Table1 = Nothing
Set Tables = Nothing
Set DB = Nothing
Set report = Nothing
Set App = Nothing
Set parameter = Nothing
Set CRXPFDs = Nothing
Set CRXPFD = Nothing
Rcdset.MoveNext
Wend
Main = DTSTaskExecResult_Success
End Function
I have been working on the piece of code below in a DTS package. The two lines highlighted are causing problems. The 1st one I am getting an error with is saying that their is a type mismatch. In the table currentpractice is a varchar - am I declaring it incorrectly?
The second line says that there is a missing or out of date export dll.
Any ideas? I have this code working in normal visual basic.
Function Main()
Main = DTSTaskExecResult_Success
Dim Conn 'ADO Connection
Dim Comm 'ADO Command
Dim Rcdset 'ADO Recordset
Dim App
Dim report 'Crystal Report
Dim DB 'Crystal Database
Dim Tables 'Crystal DatabaseTables
Dim Table1 'Crystal DatabaseTable
Dim currentpractice
currentpractice = 2A
Dim final
Set Conn = CreateObject("ADODB.Connection")
Set Comm = CreateObject("ADODB.Command")
Set Rcdset = CreateObject("ADODB.Recordset")
Conn.Open "Provider=SQLOLEDB.1;Initial Catalog=E_Audit_Database;App=Crystal Export;Data Source=(local)", "**", "*****"
'Comm.ActiveConnection = Conn
final = "final_reports_last_generated"
Rcdset.Open final, Conn, adOpenStatic, , adCmdTable
While (NOT Rcdset.EOF )
Msgbox("in the While statement")
currentpractice = Rcdset.Fields.Item(0)
Msgbox(currentpractice)
Set App = CreateObject("CrystalRuntime.application.8.5") ' This is on a machine with Crystal 8.5
Set report = App.OpenReport("Z:\report1.rpt")
report.DiscardSavedData
Set DB = report.Database
Set Tables = DB.Tables
Set Table1 = Tables.Item(1)
report.ParameterFields.Item(1).AddCurrentValue currentpractice
report.ReadRecords
report.ExportOptions.DestinationType = crEDTDiskFile
report.ExportOptions.FormatType = crEFTWordForWindows
report.ExportOptions.DiskFileName = "C:\TEST\diditwork.rtf"
'report.Export False
Set Table1 = Nothing
Set Tables = Nothing
Set DB = Nothing
Set report = Nothing
Set App = Nothing
Set parameter = Nothing
Set CRXPFDs = Nothing
Set CRXPFD = Nothing
Rcdset.MoveNext
Wend
Main = DTSTaskExecResult_Success
End Function