DataSpace Object and CreateObject Method Example (VBScript)
Article
The following example shows how to use the CreateObject method of the RDS.DataSpace with the default business object, RDSServer.DataFactory. To test this example, cut and paste this code between the <Body> and </Body> 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 adovbs.inc-->
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>
</body>
</html>
<!-- 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