<%
dim connect, rs, sql, tr, totrec
set connect = server.createobject("ADODB.Connection")
' ==========
' It have many method to open file. Some method does not work.
' connect.open("DRIVER={Microsoft Access Driver (*.mdb)}; DBQ=" & Server.MapPath("quizans.mdb"))
' connect.open("DRIVER={Microsoft Access Driver (*.mdb)}; DBQ=" & Server.MapPath("\yourdir\db\quizans.mdb"))
' connect.open("DRIVER={Microsoft Access Driver (*.mdb)}; DBQ=d:\thaiall.com\allthai.quiz\quizans.mdb")
connect.open "provider=microsoft.jet.oledb.4.0; data source=" & Server.MapPath("quizans.mdb")
' ==========
sql = "select * from teacher where tid='" & request.form("tid") &"'"
sql = sql & " and pass ='" & request.form("pass") &"'"
set rs=server.createobject("ADODB.recordset")
rs.open sql,connect,1,3
totrec = rs.recordcount
if totrec = 0 then
response.write("Incorrect student id or password")
response.end
end if
response.write("<ol>Teacher id : " & request.form("tid"))
response.write("<br>Teacher name : " & rs("tname"))
sql = "select * from "& request.form("tbl")
set rs = server.createobject("ADODB.recordset")
rs.open sql,connect,1,3
response.write("<hr>Table : " & request.form("tbl"))
response.write("<br>Total records : " & rs.recordcount)
response.write("<br>Total fields : " & rs.fields.count)
response.write("<hr>")
for i = 0 to rs.fields.count - 1
response.write(rs(i).name &",")
next
do while not rs.eof
response.write("<li>")
for i = 0 to rs.fields.count - 1
response.write(rs(i)&",")
next
rs.movenext
loop
response.write("</ol>")
connect.close
set rs = nothing
set connect = nothing
%>
จำนวน : 43 บรรทัด