Table of contents
Collapse the table of content
Expand the table of content

DataSpace Object and CreateObject Method Example (VBScript)

office 365 dev account|Last Updated: 4/3/2018
3 Contributors

Applies to: Access 2013 | Access 2016

The following example shows how to use the CreateObject method of theRDS.DataSpace with the default business object,RDSServer.DataFactory. To test this example, cut and paste this code between the and tags in a normal HTML document and name it DataSpaceVBS.asp. ASP script will identify your server.

<!-- BeginDataSpaceVBS --><html>
<head><!--use the following META tag instead of>
<!--METADATA TYPE="typelib" uuid="00000205-0000-0010-8000-00AA006D2EA4" --><meta name="VI60_DefaultClientScript" content=VBScript>
<meta name="GENERATOR" content="Microsoft Visual Studio 6.0"><title>DataSpace Object and CreateObject Method Example (VBScript)</title>
body {font-family: 'Verdana','Arial','Helvetica',sans-serif;
}.thead {
background-color: #008080;font-family: 'Verdana','Arial','Helvetica',sans-serif;
font-size: x-small;color: white;
}.thead2 {
background-color: #800000;font-family: 'Verdana','Arial','Helvetica',sans-serif;
font-size: x-small;color: white;
}.tbody {
text-align: center;background-color: #f7efde;
font-family: 'Verdana','Arial','Helvetica',sans-serif;font-size: x-small;
<body><h1>DataSpace Object and CreateObject Method Example (VBScript)</h1> 
<H2>RDS API Code Examples</H2><HR>
<H3>Using Query Method of RDSServer.DataFactory</H3> 
<!-- RDS.DataSpace ID rdsDS--><OBJECT ID="rdsDS" WIDTH=1 HEIGHT=1
<!-- RDS.DataControl with parameters set at run time --><OBJECT classid="clsid:BD96C556-65A3-11D0-983A-00C04FC29E33"
<TR><TD><SPAN DATAFLD="FirstName"></SPAN></TD>
<TD><SPAN DATAFLD="LastName"></SPAN></TD></TR>
<H4>Click Run -The <i>CreateObject</i> Method of the RDS.DataSpace Object Creates an instance of the RDSServer.DataFactory.
The <i>Query</i> Method of the RDSServer.DataFactory is used to bring back a Recordset.</H4> 
<Script Language="VBScript"> 
Dim rdsDFDim strServer
Dim strCnxnDim strSQL 
strServer = "http://<%=Request.ServerVariables("SERVER_NAME")%>"strCnxn = "Provider='sqloledb';Data Source=" &; _
"<%=Request.ServerVariables("SERVER_NAME")%>" &; ";" &; _"Integrated Security='SSPI';Initial Catalog='Northwind';"
strSQL = "Select FirstName, LastName from Employees" 
Sub Run_OnClick() 
Dim rs' Create Data Factory
Set rdsDF = rdsDS.CreateObject("RDSServer.DataFactory", strServer)'Get Recordset
Set rs = rdsDF.Query(strCnxn, strSQL)' Use RDS.DataControl to bind Recordset to data-aware Table above
RDS.SourceRecordset = rs 
End Sub</Script> 
<!-- EndDataSpaceVBS -->

The following example shows how to use the CreateObject method to create an instance of a custom business object, VbBusObj.VbBusObjCls. It also uses the Active Server Pages scripting to identify the Web server name. To see the complete example, open the sample applications selector. In the Client Tier column, select VBScript in Internet Explorer. In the Middle Tier column, select Custom Visual Basic Business Object.

Sub Window_OnLoad() 
   strServer = "http://<%=Request.ServerVariables("SERVER_NAME")%>" 
   Set BO = ADS1.CreateObject("VbBusObj.VbBusObjCls", strServer) 
   txtConnect.Value = "dsn=Pubs;uid=MyUserId;pwd=MyPassword;" 
   txtGetRecordset.Value = "Select * From authors for Browse" 
End Sub 

Access for developers forum on MSDN
Access help on
Access help on
Search for specific Access error codes on Bing
Access forums on UtterAccess
Access wiki on UtterAcess
Access developer and VBA programming help center (FMS)
Access posts on StackOverflow

© 2018 Microsoft