Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Change table location at runtime SQL Server RAS

Status
Not open for further replies.

kifaro

Programmer
Oct 4, 2002
54
US
Hi, I currently have working code to change my tables at runtime both for the regular report and sub reports. The problem is it is so slow working and I was wondering if there was a speedier way??

'===============================================================
' CHANGING THE MAIN REPORT DATABASE INFO
'===============================================================

'Get the collection of tables in the main report
Set Tables = Session("oClientDoc" & i).DataDefController.Database.Tables
For Each table in Tables

'clone the table object
Set newTable = Table.Clone

'set the table's connectionInfo to the current connection info
newTable.ConnectionInfo = oDBInfo

'set the table object qualified name to include the new database name
'i.e. original = 'db1.dbo.myTable', new = 'db2.dbo.myTable'
newTable.QualifiedName = Database & ".dbo." & Table.Name

'put this newly modified table object back into the report client doc
Session("oClientDoc" & i).DatabaseController.SetTableLocation table, newTable

Next


'===============================================================
' CHANGING THE DATABASE FOR ALL SUBREPORTS
'===============================================================

'get a collection of subreport names
Set subReportNames = Session("oClientDoc" & i).SubReportController.QuerySubreportNames

For each subName in subReportnames

'we can't reference a subreport table object directly, so we get the collection of tables first
Set subTables = Session("oClientDoc" & i).SubReportController.GetSubreportDatabase(subName).Tables

For each subTable in subTables

'clone the subreport table object
Set newSubTable = subTable.Clone

'set the subreport table's connectionInfo to the current connection info
newSubTable.ConnectionInfo = oDBInfo

'set the table object qualified name to include the new database name
'i.e. original = 'db1.dbo.myTable', new = 'db2.dbo.myTable'

newSubTable.QualifiedName = Database & ".dbo." & subTable.Name

'put this newly modified table object back into the report client doc
Session("oClientDoc" & i).SubReportController.SetTableLocation subName, subTable, newSubTable
Next
Next
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top