Skip to content

Latest commit

 

History

History
66 lines (45 loc) · 2.09 KB

File metadata and controls

66 lines (45 loc) · 2.09 KB
title TOCTitle ms:assetid ms:mtpsurl ms:contentKeyID ms.date mtps_version ms.localizationpriority
JScript ADO programming
JScript ADO programming
2254f111-e6c2-1ad7-eb65-ee0550056d89
48543706
09/18/2015
v=office.15
medium

JScript ADO programming

Applies to: Access 2013, Office 2013

Creating an ADO Project

Microsoft JScript does not support type libraries, so you do not need to reference ADO in your project. Consequently, no associated features such as command line completion are supported. Also, by default, ADO enumerated constants are not defined in JScript.

However, ADO provides you with two include files containing the following definitions to be used with JScript:

  • For server-side scripting use Adojavas.inc, which is installed in the c:\Program Files\Common Files\System\ado\ folder by default.

  • For client-side scripting use Adcjavas.inc, which is installed in the c:\Program Files\Common Files\System\msdac\ folder by default.

You can either copy and paste constant definitions from these files into your ASP pages, or, if you are doing server-side scripting, copy Adojavas.inc file to a folder on your website and references it from your ASP page like this:

 
<!--#include File="adojavas.inc"--> 

Creating ADO Objects in JScript

You must instead use the CreateObject function call:

 
var Rs1; 
Rs1 = Server.CreateObject("ADODB.Recordset"); 

JScript Example

The following code is a generic example of JScript server-side programming in an Active Server Page (ASP) file that opens a Recordset object:

 
<%  @LANGUAGE="JScript" %> 
<!--#include File="adojavas.inc"--> 
<HTML> 
<BODY BGCOLOR="White" topmargin="10" leftmargin="10"> 
<% 
var Source = "SELECT * FROM Authors"; 
var Connect =  "Provider=sqloledb;Data Source=srv;" + 
    "Initial Catalog=Pubs;Integrated Security=SSPI;" 
var Rs1 = Server.CreateObject( "ADODB.Recordset.2.5" ); 
Rs1.Open(Source,Connect,adOpenForwardOnly); 
Response.Write("Success!"); 
%> 
</BODY> 
</HTML>