[Javascript] RE: Disconnected Recordset

Michael Dougherty Michael_Dougherty at PBP.com
Mon Feb 24 12:26:38 CST 2003


the following works fine:
<script type='text/javascript'>
  var oCN = new ActiveXObject("ADODB.Connection") ;
  var oRS = new ActiveXObject("ADODB.Recordset") ;

  oRS.CursorLocation = 3 ; /* Client-side */
  oRS.CursorType = 3 ; /* Static */
  oRS.LockType = 1 ; /* ReadOnly */

  oCN.open ("Server=MyServer;Database=MyDB;User=Me;Pwd=MyPwd'") ;
  oRS.open ("Select * from MyTable",oCN) ;

  alert( oRS.recordCount ) ;

  oRS.close ;
  oCN.close ;
</script>

What i want to do is this:
<script type='text/javascript'>
  var oCN = new ActiveXObject("ADODB.Connection") ;
  var oRS = new ActiveXObject("ADODB.Recordset") ;

  oRS.CursorLocation = 3 ; /* Client-side */
  oRS.CursorType = 3 ; /* Static */
  oRS.LockType = 1 ; /* ReadOnly */

  oCN.open ("Server=MyServer;Database=MyDB;User=Me;Pwd=MyPwd'") ;
  oRS.open ("Select * from MyTable",oCN) ;

  oRS.activeConnection = [whatever it takes to disconnect this recordset] ;

  oCN.close ; /* close the connection to the DB */

  /* use the recordset - possibly leaving it open for a while */
  alert( oRS.recordCount ) ;

  oRS.close ;
</script>

  If you don't set the activeConnection to NULL before closing the oCN
connection object, it will cause the oRS recordset object to also close.


>	I guess the first question would be, how did you get client-side
>javascript to connect to a database?  Once we understand the context,
perhaps we'll be
>able to help more.





More information about the Javascript mailing list