下面是改变为不同的数据源,从access->sql server
这个是水晶报表中的一个例子,在devloper help 中有,在调试中,出现
"could not load crdb_ado.dll"的错误
' Declare a ConnectionProperties collection.
Dim CPProperties As CRAXDRT.ConnectionProperties
' Declare a DatabaseTable object.
Dim DBTable As CRAXDRT.DatabaseTable
' Get the first table in the report.
Set DBTable = Report.Database.Tables(1)
' Get the collection of connection properties.
Set CPProperties = DBTable.ConnectionProperties
' Change the database DLL used by the report from
' native Access (crdb_dao.dll) to ADO/OLEDB (crdb_ado.dll).
DBTable.DllName = "crdb_ado.dll"
' The connection property bags contain the name and value
' pairs for the native Access DLL (crdb_dao.dll). So we need
' to clear them, and then add the name and value pairs that
' are required to connect to the OLEDB data source.
' Clear all the ConnectioProperty objects from the collection.
CPProperties.DeleteAll
' Add the name value pair for the provider.
CPProperties.Add "Provider", "SQLOLEDB"
' Add the name value pair for the data source (server).
CPProperties.Add "Data Source", "ServerA"
' Add the name value pair for the database.
CPProperties.Add "Initial Catalog", "pubs"
' Add the name value pair for the user name.
CPProperties.Add "User ID", "UserName"
' Add the name value pair for the password.
CPProperties.Add "Password", "password"
' Set the table name.
DBTable.Location = "Customer"
Screen.MousePointer = vbHourglass
' Set the report source of the viewer and view the report.
CRViewer91.ReportSource = Report
CRViewer91.ViewReport
Screen.MousePointer = vbDefault