When attempting to update the datasource/logon information for a custom query ("command table") in ASP I get the following error:
The table 'Command' could not be found. Error in File C:\WINNT\TEMP\{470A41B4-5650-4D2B-BC91-BB53D32C7B60}.rpt: The table could not be found.
It appears that when I'm changing the datasource/logon information for the custom query it changes it to a regular table which does not exist in the database. Does anyone know a way to correct this problem? The current code that's being used to set the database/logon information for the report is as follows:
Function setLogon()
Dim ConInfos
Dim newUSR, newPWD
Dim newSqlServerDescription, newDBQ,newConInfos, newInitCatalog
Dim rasTables, rasTable,newTable
Dim oldConnectionInfo,newConnectionAttributes,newConnectionInfo,ConnectionProp
Dim SubreportName
Set ConInfos = objFactory.CreateObject("CrystalReports.ConnectionInfos")
' define new server/db/username/password
newDBQ = AppDsn
newInitCatalog = AppDsn
newUSR = AppDsnUser
newPWD = AppDsnPassword
newSqlServerDescription = AppDsnServer
'----------------------------------------
'----------------------------------------
Set newConnectionAttributes = Server.CreateObject("CrystalReports.PropertyBag")
'SQL
newConnectionAttributes.EnsureCapacity 5
newConnectionAttributes.item("QE_DatabaseType") = "OLE DB (ADO)"
newConnectionAttributes.item("Database DLL") = "crdb_ado.dll"
newConnectionAttributes.item("QE_ServerDescription") = newSqlServerDescription
newConnectionAttributes.item("QE_SQLDB") = true
'-----------------------------------------------------------
' first four item are a single prop, the fifth is an object
' containing 10 single properties
'-----------------------------------------------------------
Set ConnectionProp = Server.CreateObject("CrystalReports.PropertyBag")
ConnectionProp.EnsureCapacity 10
ConnectionProp.item("Connect Timeout") = 15
'----------------------------------
' is the name of DBServer
'----------------------------------
ConnectionProp.item("Data Source") = newSqlServerDescription
ConnectionProp.item("Extended Properties") = "Use Encryption for Data=0;Replication server name connect option=;Tag with column collation when possible=0"
ConnectionProp.item("General Timeout") = 0
ConnectionProp.item("Initial Catalog") = newInitCatalog
ConnectionProp.item("Integrated Security") = false
ConnectionProp.item("Locale Identifier") = 1033
ConnectionProp.item("OLE DB Services") = -5
ConnectionProp.item("PreQEServerType") = "OLE DB (ADO)"
ConnectionProp.item("Provider") = "SQLOLEDB"
newConnectionAttributes.item("QE_logonProperties") = ConnectionProp
'----------------------------------=======------------------------
' ok, now new table should contain the right ConnectionAttributes
'-----------------------------------------------------------------
Set newConnectionInfo = Server.CreateObject("CrystalReports.ConnectionInfo")
' ALL properties must be properly set; if not, there are errors
newConnectionInfo.Attributes = newConnectionAttributes
newConnectionInfo.UserName = newUSR
newConnectionInfo.Password = newPWD
newConnectionInfo.Kind = 5
Set rasTables = oClientDoc.Database.Tables
'----------------------------------
' All tables (sps) in main report
'----------------------------------
For Each rasTable In rasTables
' connectioInfo must be provided for each table
Set newTable = Server.CreateObject("CrystalReports.Table")
Set newTable = rasTable.Clone( true)
newTable.ConnectionInfo = newConnectionInfo
'--------------------------------------
'!important! change Qualified name !
'--------------------------------------
newTable.QualifiedName = newDBQ & ".dbo." & newTable.Name
oClientDoc.DatabaseController.SetTableLocation rasTable, newTable
Set newTable = Nothing
Next 'Main report
'----------------------------------
' Subreports
'----------------------------------
For Each Subreportname In oClientDoc.Subreportcontroller.Querysubreportnames
Set rasTables = oClientDoc.Subreportcontroller.Getsubreportdatabase(Subreportname)
For Each rasTable In rasTables.Tables
Set newTable = Server.CreateObject("CrystalReports.Table")
Set newTable = rasTable.Clone(true)
newTable.ConnectionInfo = newConnectionInfo
newTable.QualifiedName = newDBQ & ".dbo." & newTable.Name
oClientDoc.SubreportController.SetTableLocation SubReportName, rasTable, newTable
Set newTable = Nothing
Next
set rasTables = nothing
Next
Set newConnectionAttributes = nothing
Set newConnectionInfo = nothing
setLogon = True
End Function
The table 'Command' could not be found. Error in File C:\WINNT\TEMP\{470A41B4-5650-4D2B-BC91-BB53D32C7B60}.rpt: The table could not be found.
It appears that when I'm changing the datasource/logon information for the custom query it changes it to a regular table which does not exist in the database. Does anyone know a way to correct this problem? The current code that's being used to set the database/logon information for the report is as follows:
Function setLogon()
Dim ConInfos
Dim newUSR, newPWD
Dim newSqlServerDescription, newDBQ,newConInfos, newInitCatalog
Dim rasTables, rasTable,newTable
Dim oldConnectionInfo,newConnectionAttributes,newConnectionInfo,ConnectionProp
Dim SubreportName
Set ConInfos = objFactory.CreateObject("CrystalReports.ConnectionInfos")
' define new server/db/username/password
newDBQ = AppDsn
newInitCatalog = AppDsn
newUSR = AppDsnUser
newPWD = AppDsnPassword
newSqlServerDescription = AppDsnServer
'----------------------------------------
'----------------------------------------
Set newConnectionAttributes = Server.CreateObject("CrystalReports.PropertyBag")
'SQL
newConnectionAttributes.EnsureCapacity 5
newConnectionAttributes.item("QE_DatabaseType") = "OLE DB (ADO)"
newConnectionAttributes.item("Database DLL") = "crdb_ado.dll"
newConnectionAttributes.item("QE_ServerDescription") = newSqlServerDescription
newConnectionAttributes.item("QE_SQLDB") = true
'-----------------------------------------------------------
' first four item are a single prop, the fifth is an object
' containing 10 single properties
'-----------------------------------------------------------
Set ConnectionProp = Server.CreateObject("CrystalReports.PropertyBag")
ConnectionProp.EnsureCapacity 10
ConnectionProp.item("Connect Timeout") = 15
'----------------------------------
' is the name of DBServer
'----------------------------------
ConnectionProp.item("Data Source") = newSqlServerDescription
ConnectionProp.item("Extended Properties") = "Use Encryption for Data=0;Replication server name connect option=;Tag with column collation when possible=0"
ConnectionProp.item("General Timeout") = 0
ConnectionProp.item("Initial Catalog") = newInitCatalog
ConnectionProp.item("Integrated Security") = false
ConnectionProp.item("Locale Identifier") = 1033
ConnectionProp.item("OLE DB Services") = -5
ConnectionProp.item("PreQEServerType") = "OLE DB (ADO)"
ConnectionProp.item("Provider") = "SQLOLEDB"
newConnectionAttributes.item("QE_logonProperties") = ConnectionProp
'----------------------------------=======------------------------
' ok, now new table should contain the right ConnectionAttributes
'-----------------------------------------------------------------
Set newConnectionInfo = Server.CreateObject("CrystalReports.ConnectionInfo")
' ALL properties must be properly set; if not, there are errors
newConnectionInfo.Attributes = newConnectionAttributes
newConnectionInfo.UserName = newUSR
newConnectionInfo.Password = newPWD
newConnectionInfo.Kind = 5
Set rasTables = oClientDoc.Database.Tables
'----------------------------------
' All tables (sps) in main report
'----------------------------------
For Each rasTable In rasTables
' connectioInfo must be provided for each table
Set newTable = Server.CreateObject("CrystalReports.Table")
Set newTable = rasTable.Clone( true)
newTable.ConnectionInfo = newConnectionInfo
'--------------------------------------
'!important! change Qualified name !
'--------------------------------------
newTable.QualifiedName = newDBQ & ".dbo." & newTable.Name
oClientDoc.DatabaseController.SetTableLocation rasTable, newTable
Set newTable = Nothing
Next 'Main report
'----------------------------------
' Subreports
'----------------------------------
For Each Subreportname In oClientDoc.Subreportcontroller.Querysubreportnames
Set rasTables = oClientDoc.Subreportcontroller.Getsubreportdatabase(Subreportname)
For Each rasTable In rasTables.Tables
Set newTable = Server.CreateObject("CrystalReports.Table")
Set newTable = rasTable.Clone(true)
newTable.ConnectionInfo = newConnectionInfo
newTable.QualifiedName = newDBQ & ".dbo." & newTable.Name
oClientDoc.SubreportController.SetTableLocation SubReportName, rasTable, newTable
Set newTable = Nothing
Next
set rasTables = nothing
Next
Set newConnectionAttributes = nothing
Set newConnectionInfo = nothing
setLogon = True
End Function