<%@ Language=VBScript %>
<HTML>
<HEAD>
</HEAD>
<BODY bgcolor=Lavender>
<%
bErr = false
mvNext = false
mvPrev = false
if Request.Form("drvtxt").Count
<> 0 then
drv = Request.Form("drvtxt")
url = Request.Form("urltxt")
uid = Request.Form("uidtxt")
pwd = Request.Form("pwdtxt")
dim
DrvArry(15)
DrvArry(0) = "--Please select
a driver--"
DrvArry(1) = "sun.jdbc.odbc.JdbcOdbcDriver"
DrvArry(2) = "sun.jdbc.odbc.JdbcOdbcDriver"
DrvArry(3) = "oracle.jdbc.driver.OracleDriver"
DrvArry(4) = "com.informix.jdbc.IfxDriver"
DrvArry(5) = "twz1.jdbc.mysql.jdbcMysqlDriver"
DrvArry(6) = "org.gjt.mm.mysql.Driver"
DrvArry(7) = "com.sybase.jdbc2.jdbc.SybDriver"
DrvArry(8) = "COM.cloudscape.core.JDBCDriver"
DrvArry(9) = "postgresql.Driver"
DrvArry(10) = "intersolv.jdbc.sequelink.SequeLinkDriver"
DrvArry(11) = "intersolv.jdbc.sequelink.SequeLinkDriver"
DrvArry(12) = "intersolv.jdbc.sequelink.SequeLinkDriver"
DrvArry(13) = "intersolv.jdbc.sequelink.SequeLinkDriver"
DrvArry(14) = "intersolv.jdbc.sequelink.SequeLinkDriver"
DrvArry(15) = "openlink.jdbc2.Driver"
select
case drv
case 1, 14:
dbms
= "Access"
case 2, 13, 15:
dbms
= "SQLServer"
case 3, 10:
dbms
= "Oracle"
case 4, 11:
dbms
= "Informix"
case 5, 6:
dbms
= "MySQL"
case 7, 12:
dbms
= "Sybase"
case 8:
dbms
= "Cloudscape"
case 9:
dbms
= "Postgres"
case else
dbms
= ""
end select
strCnn
= "Driver=" & DrvArry(drv) & ";URL=" &
url
& ";UID="
& uid & ";PWD=" & pwd & ";"
Set
conn = Server.CreateObject("ADODB.CONNECTION")
conn.Open strCnn
set
Session("authorsRd") = Server.CreateObject("ADODB.RECORDSET")
Session("authorsRd").CursorLocation
= 3
Session("authorsRd").Open
"Authors", conn, 2, 2
else
dbms = Request.QueryString("dbms")
end if
set RS = Session("authorsRd")
mode = CInt(
Request.QueryString("mode") )
If mode = 1 then
direction = CInt( Request.QueryString("direction")
)
select
case direction
case 1:
If
not RS.Eof or not RS.Bof then
RS.MoveFirst
End
If
case 2:
If
not RS.BOF Then
RS.MovePrevious
mvPrev
= true
End
If
case 3:
If
not RS.EOF Then
RS.MoveNext
mvNext
= true
End
If
case 4:
If
not RS.Eof or not RS.Bof then
RS.MoveLast
End
If
end select
If not RS.BOF or not RS.EOF then
If RS.EOF and mvNext
Then
RS.MoveLast
elseif RS.EOF then
RS.Requery
End If
If
RS.BOF and mvPrev Then
RS.MoveFirst
elseif RS.BOF then
RS.Requery
End If
End If
elseif mode = 2 then
operate = CInt( Request.QueryString("operate")
)
select
case operate
case 1:
case 2:
If
RS.RecordCount > 0 then
RS.Delete
RS.MoveNext
if
RS.RecordCount > 0 and RS.BOF then
RS.MoveFirst
end
if
End
If
case 3:
if
not RS.EOF and not RS.EOF then
for
i = 0 to RS.Fields.Count - 1
on
error resume next
fdType
= RS(i).type
if IsNull(RS(i).value) then
fdValue
= ""
else
fdValue
= RS(i).value
end
if
name
= "S" & CStr(i)
txtVal
= Request.Form(name)
if
IsNull(txtVal) or IsEmpty(txtVal) then
txtVal
= ""
end
if
if
Server.URLEnCode(txtVal) <> Server.URLEnCode(fdValue) then
if
Len(txtVal) = 0 then
RS(i)
= null
else
select
case fdType
case
16, 2, 3, 20, 17, 18, 19, 21, 4, 5, 6, 14, 131, 11
if
IsNumeric(txtVal) then
RS(i)
= txtVal
else
bErr
= true
msgErr
= fdName & " must be numeric data. Please go back."
end
if
case
else
RS(i)
= txtVal
end
select
end
if
end
if
next
if
bErr = false then
RS.Update
end
if
on
error goto 0
end if
case 5:
on
error resume next
RS.AddNew
for
i = 0 to RS.Fields.Count - 1
fdType
= RS(i).type
name
= "S" & CStr(i)
txtVal
= Request.Form(name)
if
IsNull(txtVal) or IsEmpty(txtVal) then
txtVal
= ""
end
if
if
Len(txtVal) <> 0 then
select
case fdType
case
16, 2, 3, 20, 17, 18, 19, 21, 4, 5, 6, 14, 131, 11
if
IsNumeric(txtVal) then
RS(i)
= txtVal
else
bErr
= true
msgErr
= fdName & " must be numeric data. Please go back."
end
if
case
else
RS(i)
= txtVal
end
select
end
if
next
if
bErr = false then
RS.Update
RS.MoveLast
else
RS.CancelUpdate
end
if
on
error goto 0
end select
End If
%>
<%if bErr then
Response.write msgErr
else%>
<font size="4" face="Arial, Helvetica">
<b>Database's Operation Sample</b></font><br>
<hr>
<form name=form1 method=Post action="authors.asp">
<CENTER><TABLE><TR>
<% if mode = 1 then%>
<TD>
<input type=button name=Browsebt value="Browse Mode" disabled>
<input type=button name=Editbt value="Edit Mode" onClick="ModeClick(2);">
</TD>
<TD width=10> </TD>
<TD>
<input type=button name=MoveFirst value=" |< " onClick="MoveClick(1);">
<input type=button name=MovePrevious value=" < " onClick="MoveClick(2);">
<input type=button name=MoveNext value=" > " onClick="MoveClick(3);">
<input type=button name=MoveLast value=" >| " onClick="MoveClick(4);">
</TD>
</TR>
<% elseif mode = 2 then%>
<TD>
<input type=button name=Browsebt value="Browse Mode" onClick="ModeClick(1);">
<input type=button name=Editbt value="Edit Mode" disabled>
</TD>
<TD width=10> </TD>
<TD>
<% if operate = 1 then%>
<input type=button name=Insertbt value="Insert" disabled>
<input type=button name=Deletebt value="Delete" disabled>
<% else%>
<input type=button name=Insertbt value="Insert" onClick="OperateClick(1);">
<input type=button name=Deletebt value="Delete" onClick="OperateClick(2);">
<% end if
if operate = 1 then%>
<input type=button name=Updatebt value="Update" onClick="OperateClick(5);">
<% else%>
<input type=button name=Updatebt value="Update" onClick="OperateClick(3);">
<% end if%>
<input type=button name=Cancelbt value="Cancel" onClick="OperateClick(4);">
</TD>
</TR>
<% end if%>
</TABLE>
<BR>
<TABLE>
<% for i = 0 to RS.Fields.Count - 1%>
<TR>
<TD align=right><strong><%=RS(i).name%>:</strong></TD>
<TD>
<% if mode = 1 then%>
<%if RS.BOF or RS.EOF then%>
<INPUT type=text name=S<%=i%>
disabled size=38>
<%else
if isNull(RS(i).value) or isEmpty(RS(i).value) then%>
<INPUT name=S<%=i%>
disabled size=38 value="">
<% else%>
<INPUT name=S<%=i%>
disabled size=38 value="<%=Replace(RS(i).value,
"""", """)%>">
<%
end if
end if
elseif mode = 2 then
if RS.BOF or RS.EOF or operate = 1
then
%>
<input type=text name=S<%=i%>
size=38>
<%
else
if isNull(RS(i).value) or isEmpty(RS(i).value)
then
%>
<INPUT name=S<%=i%>
size=38 value="">
<% else%>
<INPUT name=S<%=i%>
size=38 value="<%=Replace(RS(i).value,
"""", """)%>">
<%
end
if
end if
end if
%>
</TD></TR>
<%
next
%>
</TABLE>
</CENTER>
<hr size="1" color="#000000">
<EM>This is <%=dbms%>
database.</EM>
<font size="+1"><center><a href="default.asp">Return
Home</a></center></font>
</FORM>
<%end if%>
|