rogersw
Posts: 16
|
Posted: 01/23/2006, 2:30 PM |
|
If you want to use the same Grid to display data from different database connections:
1. Set up each Connection in the CCS.
2. Code your SQL statements to utilize the same number of output columns and aliases
3. In the BeforeSelect event set the proper connection.
4. In the BeforeBuildSelect event set the proper SQL and CountSQL.
Example:
Function EDMS_DataSource_BeforeBuildSelect(Sender) 'EDMS_DataSource_BeforeBuildSelect @4-4125F22C
'Custom Code @26-73254650
Dim databaseParam : databaseParam = CCGetRequestParam("database",ccsGet)
select case lcase(databaseParam)
case "edms"
EDMS.DataSource.SQL = "select " & _
"DocCtrlNum As COL1, " & _
"Doctype as COL2, " & _
"Version As COL3, " & _
"Location As COL4 " & _
"from control"
EDMS.DataSource.CountSQL = "SELECT COUNT(*) FROM control cnt"
case "staff"
EDMS.DataSource.SQL = "select " & _
"vchrPrefix As COL1, " & _
"vchrFirstName as COL2, " & _
"vchrLastName As COL3, " & _
"vchrSuffix As COL4 " & _
"from vwStaffDirectoryCruiser"
EDMS.DataSource.CountSQL = "select Count(*) from vwStaffDirectoryCruiser cnt"
case "links"
EDMS.DataSource.SQL = "select " & _
"Title AS COL1, " & _
"URL AS COL2, " & _
"Description AS COL3, " & _
"LinkOwner AS Col4 " & _
"FROM linksql.lsql_Links"
EDMS.DataSource.CountSQL = "select count(*) from linksql.lsql_Links cnt"
case else
end select
Function EDMS_BeforeSelect(Sender) 'EDMS_BeforeSelect @4-509F9A80
'Custom Code @28-73254650
Dim databaseParam : databaseParam = CCGetRequestParam("database",ccsGet)
select case lcase(databaseParam)
case "edms"
set EDMS.DataSource.Connection = new clsDBEDMS
case "staff"
set EDMS.DataSource.Connection = new clsDBStaff
case "links"
set EDMS.DataSource.Connection = new clsDBLinks
case else
exit function
end select
EDMS.DataSource.Connection.Open
'End Custom Code
End Function 'Close EDMS_BeforeSelect @4-54C34B28
|