Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Remote Data Services

Status
Not open for further replies.

studybum

Programmer
Feb 24, 2001
14
0
0
US
We are trying to access an access database located on the server via an html page using rds. Is this the best solution? If so, how do you make the connection to the database and write to it? The code we have is as follows but throws an error on the sql statement. What am I missing?

<SCRIPT Language=&quot;VBScript&quot;>

Dim myquery
Dim dcRegistration
Dim dcClasses
Dim choice

Set dcRegistration=CreateObject(&quot;RDS.DataControl&quot;)
dcRegistration.Server=&quot;dcRegistration.Connect=&quot;DSN=StudentRegSystem.mdb&quot;
dcClasses.SQL=&quot;SELECT * FROM CourseSection&quot;
dcClasses.Refresh

Sub Submit_OnClick

myquery = &quot;SELECT * FROM CourseSection WHERE CourseNumber LIKE '&quot; + choice.Item + &quot;'&quot;

dcClasses.SQL = myquery
dcClasses.Refresh
End Sub


</Script>
 
Here is some MSDN sample code and help
Code:
<!-- BeginDataFactoryVBS -->
<HTML>
<HEAD>
<!--use the following META tag instead of adovbs.inc-->
<!--METADATA TYPE=&quot;typelib&quot; uuid=&quot;00000205-0000-0010-8000-00AA006D2EA4&quot; -->
<META name=&quot;VI60_DefaultClientScript&quot; Content=&quot;VBScript&quot;>

<META NAME=&quot;GENERATOR&quot; Content=&quot;Microsoft Visual Studio 6.0&quot;>
<TITLE>DataFactory Object, Query Method, and 
CreateObject Method Example (VBScript)</TITLE>
<style>
<!--
body {
   font-family: 'Verdana','Arial','Helvetica',sans-serif;
   BACKGROUND-COLOR:white;
   COLOR:black;
    }
.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;
    }
-->
</style>
</HEAD>
<BODY>
<h1>DataFactory Object, Query Method, and 
CreateObject Method Example (VBScript)</h1>
<H2>RDS API Code Examples</H2>
<HR>
<H3>Using Query Method of RDSServer.DataFactory</H3>

<!-- RDS.DataSpace  ID RDS1-->
<OBJECT ID=&quot;RDS1&quot; WIDTH=1 HEIGHT=1
CLASSID=&quot;CLSID:BD96C556-65A3-11D0-983A-00C04FC29E36&quot;>
</OBJECT>

<!-- RDS.DataControl with parameters 
set at run time -->
<OBJECT classid=&quot;clsid:BD96C556-65A3-11D0-983A-00C04FC29E33&quot;
   ID=RDS WIDTH=1 HEIGHT=1>
</OBJECT>

<TABLE DATASRC=#RDS>
<TBODY>
  <TR>
    <TD><SPAN DATAFLD=&quot;FirstName&quot;></SPAN></TD>
    <TD><SPAN DATAFLD=&quot;LastName&quot;></SPAN></TD>
  </TR>
</TBODY>    
</TABLE>

<HR>
<INPUT TYPE=BUTTON NAME=&quot;Run&quot; VALUE=&quot;Run&quot;>
<BR>
<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=&quot;VBScript&quot;>

   Dim rdsDF
   Dim strServer
   Dim strCnxn
   Dim strSQL

   strServer = &quot;[URL unfurl="true"]http://<%=Request.ServerVariables(&quot;SERVER_NAME&quot;)%>&quot;[/URL]
   strCnxn = &quot;Provider=SQLOLEDB;User Id=sa;Password=;Initial Catalog=Northwind;&quot;
   strSQL = &quot;Select FirstName, LastName from Employees&quot;

   Sub Run_OnClick()
   
      ' Create RDSServer.DataFactory Object
         Dim rs
      ' Get Recordset
         Set DF = RDS1.CreateObject(&quot;RDSServer.DataFactory&quot;, strServer)
         Set rs = DF.Query(strCnxn, strSQL)
      ' Set parameters of RDS.DataControl at Run Time
         RDS.Server = strServer
         RDS.SQL = strSQL
         RDS.Connect = strCnxn
         RDS.Refresh
         
   End Sub
</Script>


</BODY>
</HTML>
<!-- EndDataFactoryVBS -->
________
George, M
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top