%@LANGUAGE=VBScript%>
<%
Const adOpenStatic = 3
Const adLockReadOnly = 1
Const adCmdText = &H0001
' Define variables
dim recordsonpage, requestrecords, offset, allrecords, hiddenrecords, showrecords, lastrecord, recordcounter, pagelist, pagelistcounter
dim val
if Request.QueryString("val")<> "" then
value=Request.querystring("val")
val=server.htmlencode(Request.querystring("val"))&"%"
cmd="select * from Table1 where Product_Name like '"&val&"' "
elseif Request.Form("val")<>"" then
val=server.htmlencode(Request.Form("val"))
fieldvalue=val
cmd=("select * from Table1 where (Product_Name like '%" & val & "%') OR (Art_No like '%" & val & "%') ")
end if
if request.QueryString("field")<>"" and request.QueryString("val")="" then
fieldvalue=trim(request.QueryString("field"))
cmd=("select * from Table1 where (Product_Name like '%" & fieldvalue & "%') OR (Art_No like '%" & fieldvalue & "%') ")
end if
' DB connection
dim Conn
Set Conn = Server.CreateObject("ADODB.Connection")
sConnection = "Provider=Microsoft.Jet.OLEDB.4.0;" & _
"Data Source=" & Server.MapPath("product.mdb") & ";" & _
"Persist Security Info=True"
Conn.Open(sConnection)
' records per page
'recordsonpage = 20
' count all records
'allrecords = 0
'set rs = conn.Execute(cmd)
'do until rs.EOF
'allrecords = allrecords + 1
' rs.movenext
'loop
' if offset is zero then the first page will be loaded
'offset = request.querystring("offset")
'if offset = 0 OR offset = "" then
' requestrecords = 0
'else
'requestrecords = requestrecords + offset
'end if
' opens database
if Request.Form("val")="" and request.QueryString("val")="" and request.QueryString("field")="" then
cmd="select * from Table1"
end if
Set rs=Server.CreateObject("adodb.recordset")
' rs.Open cmd,conn
Rs.Open cmd,Conn,adOpenStatic, adLockReadOnly, adCmdText
Rs.PageSize =20
nPageCount =Rs.PageCount
nPage=1
if not Rs.Eof then
if(Trim(Request.QueryString("page"))<>"") then
nPage = Trim(Request.QueryString("page"))
end if
Rs.AbsolutePage =cint(nPage)
'hiddenrecords = requestrecords
'do until hiddenrecords = 0 OR rs.EOF
' hiddenrecords = hiddenrecords - 1
' rs.movenext
' if rs.EOF then
' lastrecord = 1
' end if
'loop
%>
<%
' prints records in the table
'showrecords = recordsonpage
'recordcounter = requestrecords
'do until showrecords = 0 OR rs.EOF
'recordcounter = recordcounter + 1
while not ( Rs.AbsolutePage <>cint(nPage) OR Rs.eof )
%>
<%= Rs("Art_No") %>
<%=rs("Product_Name") %>
<%=rs("packing") %>
<%
'showrecords = showrecords - 1
rs.movenext
' if rs.EOF then
' lastrecord = 1
'loop
wend
' end if
%>