<% Language=VBScript
%>
<% Session.timeout = 1800 %>
<html>
<head>
<meta http-equiv="Content-Type"
content="text/html; charset=iso-8859-1">
<meta name="GENERATOR" content="Microsoft
FrontPage Express 2.0">
<title></title>
</head>
<body
bgcolor="#FEFBC5">
<table
border="0" width="100%">
<tr>
<td width="100%" bgcolor="#800000"><font color="#FEFBD5"
size="5">Connecting to MS Access from IASP using RJAX (DSN)</font></td>
</tr>
</table>
<p><br>
<!--#include file="GetConn.inc"-->
<%
If Not IsObject(Session("db_rs"))
Then
Dim
sql
Dim activeConn
Dim cursorType
Dim lockType
cursorType
= 3
lockType = 3
activeConn
= conn
sql
= "SELECT * FROM Authors"
'
create the Recordset object...
Set rs = Server.CreateObject("ADODB.Recordset")
rs.PageSize
= 10
rs.Open
sql, activeConn, cursorType, lockType, 8
set
Session("db_rs") = rs
Dim
pageNum
pageNum
= 1
rs.AbsolutePage
= pageNum
Session("PageNumber")
= 1
Else
set
rs = Session("db_rs")
tempPageNum = Session("PageNumber")
If
(request.queryString("direction") = "forward") Then
If (tempPageNum=rs.PageCount)
Then
tempPageNum = 1
Else
tempPageNum = tempPageNum + 1
End If 'tempPageNum=0
ElseIf
(request.queryString("direction") = "back") Then
If (tempPageNum=1)
Then
tempPageNum = rs.PageCount
Else
tempPageNum = tempPageNum - 1
End If 'tempPageNum=0
ElseIf
(request.queryString("direction") = "first") Then
tempPageNum = 1
ElseIf
(request.queryString("direction") = "last") Then
tempPageNum = rs.PageCount
End
If 'direction=back
pageNum
= tempPageNum
rs.AbsolutePage
= pageNum
Session("PageNumber")
= tempPageNum
End If
%>
</p>
<table
border="0">
<tr>
<td><strong>Database: Biblio<br>
Table: Authors</strong> </td>
<td> </td>
</tr>
<tr>
<td><!-- Table to display the data --> <table border="1">
<tr>
<td>Auth_Id</td>
<td>Author</td>
<td>Year Born</td>
</tr>
<%
Dim fields
Dim field
Dim
fldIndex
i = 0
While(i<rs.PageSize And rs.EOF<>true)
Response.Write "<tr>"
For count=0 To rs.Fields.Count-1
val = rs.Fields.item(count).value
Response.Write "<td>"
& val & "</td>"
Next
Response.Write "</tr>"
rs.MoveNext
i=i+1
Wend
%>
<tr>
<td colspan="3"><table border="0" cellpadding="0"
width="100%">
<tr>
<td bgcolor="#800000"><a
href="DispAuthors.asp?direction=first"><font
color="#FFFF00" size="2" face="Verdana"><strong><<Move
First</strong></font></a></td>
<td bgcolor="#800000"><a
href="DispAuthors.asp?direction=back"><font
color="#FFFF00" size="2" face="Verdana"><strong><Prev</strong></font></a></td>
<td align="right" bgcolor="#800000"><a
href="DispAuthors.asp?direction=forward"><font
color="#FFFF00" size="2" face="Verdana"><strong>Next></strong></font></a></td>
<td bgcolor="#800000"><a
href="DispAuthors.asp?direction=last"><font
color="#FFFF00" size="2" face="Verdana"><strong>Move
Last>></strong></font></a></td>
</tr>
</table>
</td>
</tr>
</table>
</td>
<td valign="top"><form action="AddAuthor.asp"
method="POST">
<table border="0">
<tr>
<td align="right" valign="top">Author: </td>
<td valign="top"><input type="text" size="25"
name="Author"></td>
</tr>
<tr>
<td align="right" valign="top">Year Born:</td>
<td valign="top"><input type="text" size="25"
name="YearBorn"></td>
</tr>
<tr>
<td align="right" valign="bottom" colspan="2"><input
type="submit" value="Add New"></td>
</tr>
</table>
</form>
</td>
</tr>
</table>
</body>
</html>
|
<% Language=VBScript
%>
<% Session.timeout = 1800 %>
<html>
<head>
<meta http-equiv="Content-Type"
content="text/html; charset=iso-8859-1">
<meta name="GENERATOR" content="Microsoft
FrontPage Express 2.0">
<title></title>
</head>
<body
bgcolor="#FEFBC5">
<table
border="0" width="100%">
<tr>
<td width="100%" bgcolor="#800000"><font color="#FEFBD5"
size="5">Connecting to MS Access from IASP using RJAX (DSN)</font></td>
</tr>
</table>
<p><br>
<!--#include file="GetConn.inc"--><%
If Not IsObject(Session("db_rs"))
Then
'
Variant parameters are set in a special fashion. First, a Variant
Object is created as follows
Set
sql = Server.CreateObject("hs.types.Variant")
Set activeConn = Server.CreateObject("hs.types.Variant")
Set cursorType = Server.CreateObject("hs.types.Variant")
Set lockType = Server.CreateObject("hs.types.Variant")
'
then the desired values are set in the following manner
cursorType.setInt 3
lockType.setInt 3
'
getting Active Connection to be set in activeConn
set activeXObj = conn.getActiveX()
'
setting Active Connection to Variant Type Object
activeConn.setActiveX activeXObj
'
setting the sql string in Variant Object
sql.setString
"SELECT * FROM Authors"
'
create rjaxADODB.Recordset instead of ADODB.Recordset
Set rs
= Server.CreateObject("rjaxADODB.Recordset")
'
getting connected object of RJAX
set rjaxObj
= activeXObj.getRJAX()
'
This connected object is passed in Recordset connect(...), so that
Recordset methods could be called via RJAX
success
= rs.connect(rjaxObj)
if
(success=true) Then
Response.Write "<H2>Recordset
created</H2>"
Else
Response.Write "<H2>Recordset
Failed</H2>"
End If
rs.PageSize
= 10
rs.Open
sql, activeConn, cursorType, lockType, 8
set
Session("db_rs") = rs
'
making pageNum Variant Type
set pageNum
= Server.CreateObject("hs.types.Variant")
pageNum.setInt 1
rs.AbsolutePage
= pageNum
Session("PageNumber")
= 1
Else
set
rs = Session("db_rs")
tempPageNum = Session("PageNumber")
If
(request.queryString("direction") = "forward") Then
If (tempPageNum=rs.PageCount())
Then
tempPageNum = 1
Else
tempPageNum = tempPageNum + 1
End If 'tempPageNum=0
ElseIf
(request.queryString("direction") = "back") Then
If (tempPageNum=1)
Then
tempPageNum = rs.PageCount()
Else
tempPageNum = tempPageNum - 1
End If 'tempPageNum=0
ElseIf
(request.queryString("direction") = "first") Then
tempPageNum = 1
ElseIf
(request.queryString("direction") = "last") Then
tempPageNum = rs.PageCount()
End
If 'direction=back
'
making pageNum Variant Type
Set pageNum
= Server.CreateObject("hs.types.Variant")
pageNum.setInt tempPageNum
rs.AbsolutePage
= pageNum
Session("PageNumber")
= tempPageNum
End If
%>
</p>
<table
border="0">
<tr>
<td><strong>Database: Biblio<br>
Table: Authors</strong> </td>
<td> </td>
</tr>
<tr>
<td><!-- Table to display the data --> <table border="1">
<tr>
<td>Auth_Id</td>
<td>Author</td>
<td>Year Born</td>
</tr>
<%
Dim fields
Dim field
'
making fldIndex Variant Type by first creating Variant Object
set fldIndex = Server.CreateObject("hs.types.Variant")
i = 0
While(i<rs.PageSize() And rs.EOF()<>true)
Response.Write "<tr>"
For count=0 To rs.Fields().Count-1
'
then setting it with appropriate value
fldIndex.setInt count
'
make sure to append 'get' with both item() and value(), plus the
value received is a Variant Object
set fldVal = rs.fields.getItem(fldIndex).getValue()
Dim val
' therefore we extract its type in order to
print
set type = field.getType()
'Checking
the type of the field and getting the values accordingly
Select Case type.lVal() ' getting the
type in long value
case 2
' Long Integer
val = fldVal.lVal
case 3 'Integer
val = fldVal.lVal
case 11 'boolean
val = fldVal.bool
case 200 'String
val = fldVal.strVal
'add more
cases as required...
End Select
Response.Write "<td>"
& val & "</td>"
Next
Response.Write "</tr>"
rs.MoveNext
i=i+1
Wend
%>
<tr>
<td colspan="3"><table border="0" cellpadding="0"
width="100%">
<tr>
<td bgcolor="#800000"><a
href="DispAuthors.asp?direction=first"><font
color="#FFFF00" size="2" face="Verdana"><strong><<Move
First</strong></font></a></td>
<td bgcolor="#800000"><a
href="DispAuthors.asp?direction=back"><font
color="#FFFF00" size="2" face="Verdana"><strong><Prev</strong></font></a></td>
<td align="right" bgcolor="#800000"><a
href="DispAuthors.asp?direction=forward"><font
color="#FFFF00" size="2" face="Verdana"><strong>Next></strong></font></a></td>
<td bgcolor="#800000"><a
href="DispAuthors.asp?direction=last"><font
color="#FFFF00" size="2" face="Verdana"><strong>Move
Last>></strong></font></a></td>
</tr>
</table>
</td>
</tr>
</table>
</td>
<td valign="top"><form action="AddAuthor.asp"
method="POST">
<table border="0">
<tr>
<td align="right" valign="top">Author: </td>
<td valign="top"><input type="text" size="25"
name="Author"></td>
</tr>
<tr>
<td align="right" valign="top">Year Born:</td>
<td valign="top"><input type="text" size="25"
name="YearBorn"></td>
</tr>
<tr>
<td align="right" valign="bottom" colspan="2"><input
type="submit" value="Add New"></td>
</tr>
</table>
</form>
</td>
</tr>
</table>
</body>
</html>
|