Trying to switch btwn primary and secondary DB's...
Specifically, primary is DB2 and secondary is SQL Srvr
using the DB.SetConnection API as documented in help
Code have is:
------------------------------------------------------
dynamic datars2;
dynamic rs2 ;
// switch over to SQL SErver ...
DB.SetConnection("ODBC_lims_test"); // this is the name shown in the WIZARD connection and matches name in Web Config connection name as well
// have also tried just lims_test
sqlcmd = "select count(*) as hits from ( " +
" select sampleid,method from dbo.nye_result where processed = 0 group by sampleid,method ) a ;" ;
rs2 = DB.Query(sqlcmd);
datars2 = rs2.fetchAssoc();
if(datars2 ) {
XSession.Session["numassays"] = String.Format("{0}",datars2["HITS"]);
}
// switch back to primary connection aka DB2 ...
DB.SetConnection("");
--------------------------------------------------------
Get error: on datars2 = rs2.fetchAssoc();
Cannot perform runtime binding on a null reference
I'm guessing getting above error because it didn't connect to the DB...
Anyways, if anybody has an example of switching btwn DB's using the DB API as documented in help
Most appreciated.
Thanks
Mark