 |
|
ผมติดต่อฐานข้อมูลไม่ได้ครับ คือ ผมมี Source Code อันนี้ครับ
<%@ Language=VBScript %>
<!-- METADATA TYPE="typelib" UUID="00000200-0000-0010-8000-00AA006D2EA4" NAME="ADO Type Library"-->
<html>
<head>
<title>Web OPEC ระบบสืบค้นข้อมูลหนังสือ</title>
<style>
BODY
{
FONT-WEIGHT: normal;
FONT-SIZE: 9pt;
COLOR: black;
FONT-FAMILY: Arial, Helvetica, sans-serif;
TEXT-DECORATION: none
}
TABLE
{
FONT-WEIGHT: normal;
FONT-SIZE: 9pt;
COLOR: black;
FONT-FAMILY: Arial, Helvetica, sans-serif;
TEXT-DECORATION: none
}
A
{
FONT-WEIGHT: normal;
FONT-SIZE: 9pt;
COLOR: blue;
FONT-FAMILY: Arial, Helvetica, sans-serif;
TEXT-DECORATION: underline
}
HR
{
COLOR: #0072bc
}
</style>
</head>
<body onload="javascript: document.frmSearch.id.select();" leftmargin="0" marginwidth="0" topmargin="0" marginheight="0" bgcolor="white" text="black" link="blue" vlink="purple" alink="red">
<table border="0" width="100%">
<!--Search Form-->
<form name="frmSearch" method="post" action="<%=Request.ServerVariables("SCRIPT_NAME")%>">
<input type="hidden" name="page" value="1">
<tr>
<td align=center height="110" valign="top">
<table cellpadding="0" cellspacing="0" width="100%">
<tr>
<td width="188" align="left" height="99" background="images/TopBarBK.gif">
<p align="left"><font face="Tahoma"><span style="font-size:8pt;"><img src="images/RightTopBk.gif" width="205" height="109" border="0"></span></font></p>
</td>
<td width="801" background="images/TopBarBK.gif" height="99">
<table width="279" cellpadding="0" cellspacing="0">
<tr>
<td width="279" valign="top" height="8" colspan="2">
<p><span style="font-family:Arial,Helvetica,sans-serif; font-weight:normal; font-size:9pt; color:black; text-decoration:none;"> <font color="yellow"> </font></span><span style="font-family:Arial,Helvetica,sans-serif; font-weight:normal; font-size:8pt; color:black; text-decoration:none;"><font face="Tahoma" color="#660000"> ใส่ข้อมูลหนังสือที่ต้องการค้นหา</font></span></p>
</td>
</tr>
<tr>
<td width="165" height="16" valign="top">
<p><span style="font-family:Arial,Helvetica,sans-serif; font-weight:normal; font-size:9pt; color:black; text-decoration:none;"> </span><font face="Tahoma"><span style="font-size:8pt;"><input accesskey="i" type="text" name="id" size="24" value="<%=Server.HTMLEncode(Request("id"))%>" style="font-family:Tahoma; font-weight:normal; font-size:8pt; text-align:center;"></span></font></p>
</td>
<td width="113" height="16" valign="top">
<p><font face="Tahoma"><span style="font-size:8pt;"><INPUT id=submit1 style="font-family:Tahoma; font-style:normal; font-weight:normal; font-size:8pt; width:45px; height:22px; left:675px; top:150px;" type ="submit" size=6 value="ค้นหา" name="btnSubmit"></span></font><%
Response.Buffer = True 'Turn buffering on
Response.Expires = -1 'Page expires immediately
'Constants
Const MIN_PAGESIZE = 5 'Minimum pagesize
Const MAX_PAGESIZE = 20 'Maximum pagesize
Const DEF_PAGESIZE = 10 'Default pagesize
'Variables
Dim objCn 'ADO DB connection object
Dim objRs 'ADO DB recordset object
Dim blnWhere 'True/False for have WHERE in sql already
Dim intRecord 'Current record for paging recordset
Dim intPage 'Requested page
Dim intPageSize 'Requested pagesize
Dim sql 'Dynamic sql query string
'Create objects
Set objCn = Server.CreateObject("ADODB.Connection")
Set objRs = Server.CreateObject("ADODB.Recordset")
'Set/initialize variables
intRecord = 1
blnWhere = False
'-Get/set requested page
intPage = MakeLong(Request("page"))
If intPage < 1 Then intPage = 1
'-Get/set requested pagesize
If IsEmpty(Request("pagesize")) Then 'Set to default
intPageSize = DEF_PAGESIZE
Else
intPageSize = MakeLong(Request("pagesize"))
'Make sure it fits our min/max requirements
If intPageSize < MIN_PAGESIZE Then
intPageSize = MIN_PAGESIZE
ElseIf intPageSize > MAX_PAGESIZE Then
intPageSize = MAX_PAGESIZE
End If
End If
'-Build dynamic sql
sql = "SELECT * FROM bookmaster "
'--ID (exact search only)
If Not IsEmpty(Request("id")) Then
'If IsNumeric(Request("id")) Then
'Add to query
'First item so we don't have to test for WHERE
blnWhere = True 'Set where to true
sql = sql & "WHERE "
sql = sql & "bookreg like '%"&Request("id")&"%' or "
sql = sql & "bookname1 like '%"&Request("id")&"%' or "
sql = sql & "bookname2 like '%"&Request("id")&"%' or "
sql = sql & "booktitle like '%"&Request("id")&"%' or "
sql = sql & "bookdirector1 like '%"&Request("id")&"%' "
'End If
End If
With objCn
.CursorLocation = adUseClient
.ConnectionTimeout = 15
.CommandTimeout = 30
.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;" & _
"Data Source=" & Server.MapPath("./upcbook.mdb") & ";"
.Open
End With
'Create and open recordset object
With objRs
.ActiveConnection = objCn
.CursorLocation = adUseClient
.CursorType = adOpenForwardOnly
.LockType = adLockReadOnly
.Source = sql
.PageSize = intPageSize
.Open
Set .ActiveConnection = Nothing 'Disconnect the recordset
End With
'Creates a long value from a variant, invalid always set to zero
Function MakeLong(ByVal varValue)
If IsNumeric(varValue) Then
MakeLong = CLng(varValue)
Else
MakeLong = 0
End If
End Function
'Returns a neatly made paging string, automatically configuring for request
'variables, regardless of in querystring or from form, adjust output to your needs.
Function Paging(ByVal intPage, ByVal intPageCount, ByVal intRecordCount)
Dim strQueryString
Dim strScript
Dim intStart
Dim intEnd
Dim strRet
Dim i
If intPage > intPageCount Then
intPage = intPageCount
ElseIf intPage < 1 Then
intPage = 1
End If
If intRecordCount = 0 Then
strRet = "ไม่พบข้อมูล"
ElseIf intPageCount = 1 Then
strRet = "สิ้นสุด"
Else
For i = 1 To Request.QueryString.Count
If LCase(Request.QueryString.Key(i)) <> "page" Then
strQueryString = strQueryString & "&"
strQueryString = strQueryString & Server.URLEncode(Request.QueryString.Key(i)) & "="
strQueryString = strQueryString & Server.URLEncode(Request.QueryString.Item(i))
End If
Next
For i = 1 To Request.Form.Count
If LCase(Request.Form.Key(i)) <> "page" Then
strQueryString = strQueryString & "&"
strQueryString = strQueryString & Server.URLEncode(Request.Form.Key(i)) & "="
strQueryString = strQueryString & Server.URLEncode(Request.Form.Item(i))
End If
Next
If Len(strQueryString) <> 0 Then
strQueryString = "?" & Mid(strQueryString, 2) & "&"
Else
strQueryString = "?"
End If
strScript = Request.ServerVariables("SCRIPT_NAME") & strQueryString
If intPage <= 10 Then
intStart = 1
Else
If (intPage Mod 10) = 0 Then
intStart = intPage - 9
Else
intStart = intPage - (intPage Mod 10) + 1
End If
End If
intEnd = intStart + 9
If intEnd > intPageCount Then intEnd = intPageCount
strRet = "หน้าที่ " & intPage & " จากทั้งหมด " & intPageCount & " : "
If intPage <> 1 Then
strRet = strRet & "<a href=""" & strScript
strRet = strRet & "page=" & intPage - 1
strRet = strRet & """><<ก่อนหน้า</a> "
End If
For i = intStart To intEnd
If i = intPage Then
strRet = strRet & "<b>" & i & "</b> "
Else
strRet = strRet & "<a href=""" & strScript
strRet = strRet & "page=" & i
strRet = strRet & """>" & i & "</a>"
If i <> intEnd Then strRet = strRet & " "
End If
Next
If intPage <> intPageCount Then
strRet = strRet & " <a href=""" & strScript
strRet = strRet & "page=" & intPage + 1
strRet = strRet & """>ถัดไป>></a> "
End If
End If
Paging = strRet
End Function
%> </p>
</td>
</tr>
<tr>
<td width="279" height="4" valign="top" colspan="2">
<p><font size="1" face="Tahoma"> <br> </font></p>
</td>
</tr>
</table>
</td>
</tr>
</table>
</td>
</tr>
</form>
<%If objRs.EOF Then%>
<!--No Records Found-->
<%Else%>
<!--Records Found-->
<tr>
<td>
<table cellpadding="0" cellspacing="0" background="images/top.gif">
<tr>
<td width="979" height="28">
<p align="center"><font size="1" face="MS Sans Serif"><%if request("id")<>"" then%>
</font> <%=Paging(intPage, objRs.PageCount, objRs.RecordCount)%></p>
</td>
</tr>
</table>
<table border="0" width="100%" cellpadding="3" cellspacing="3">
<%
If objRs.PageCount < intPage Then intPage = objRs.PageCount
objRs.AbsolutePage = intPage
Dim strRowColor
strRowColor = "#ffffff"
Do While Not objRs.EOF And intRecord <= intPageSize
%>
<tr bgcolor="<%=strRowColor%>">
<td nowrap width="24" height="133">
<p> </p>
</td>
<td width="944" nowrap height="133">
<table border="0" width="100%" height="100">
<tr>
<td width="169" height="10">
<p><span style="font-size:8pt;"><font face="Tahoma" color="#6633FF"><img src="images/hot_post.gif" width="16" height="16" border="0" align="middle"> </font><b><font face="Tahoma" color="#6633FF"> </font><u><font face="Tahoma" color="#0066FF">เลขทะเบียน</font></u><font face="Tahoma" color="#0066FF"> :</font></b><font face="Tahoma" color="#0066FF"> <%=objRs("bookreg") %></font></span><font face="Tahoma" color="#6633FF"><span style="font-size:8pt;"></span><span style="font-size:8pt;"></span></font></p>
</td>
<td width="765" height="10">
<p><span style="font-size:8pt;"><b><font face="Tahoma" color="#454045"><img src="images/circle03_blue_1.gif" width="6" height="10" border="0" align="middle"></font><font face="Tahoma" color="#6633FF"> <u>ชื่อเรื่อง</u> <u>1</u> :</font></b><font face="Tahoma" color="#6633FF"> <%=objRs("bookname1")%></font><font face="Tahoma" color="royalblue"> </font><b><font face="Tahoma" color="#6633FF"> <u>ชื่อเรื่อง</u> <u>2</u> :</font></b><font face="Tahoma" color="royalblue"> </font><font face="Tahoma" color="#6633FF"><%=objRs("bookname2")%></font><font face="Tahoma" color="royalblue"> </font><font face="Tahoma" color="#FF6600"> (<%=objRs("booktype")%> )
</font></span><font face="Tahoma" color="#6633FF"><span style="font-size:8pt;"> </span></font></p>
</td>
</tr>
<tr>
<td width="169" height="12" valign="top">
<p><b><span style="font-size:8pt;"><font face="Tahoma" color="#454045"> </font></span></b><span style="font-size:8pt;"><b><u><font face="Tahoma" color="#CC0000">เลขหม</font></u><font face="Tahoma" color="#CC0000">ู่ :</font></b><font face="Tahoma" color="#CC0000"> <%=objRs("bookcode1") %></font></span><span style="font-size:8pt;"><b><font face="Tahoma" color="#454045"> </font></b></span></p>
</td>
<td width="765" height="12" valign="top">
<p><span style="font-size:8pt;"><b><font face="Tahoma" color="#454045"><img src="images/circle03_darkblue_1.gif" width="6" height="10" border="0" align="middle"> </font><u><font face="Tahoma" color="#454045">ชื่อผู้แต่ง</font></u><font face="Tahoma" color="#454045"> : </font></b><font face="Tahoma" color="#454045"><%=objRs("bookdirector1")%> ,<%=objRs("bookdirector2")%> ,<%=objRs("bookdirector3")%> ,<%=objRs("bookdirector4")%> </font></span></p>
</td>
</tr>
<tr>
<td width="169" height="8" valign="top">
<p><b><span style="font-size:8pt;"><font face="Tahoma" color="#454045"> </font></span></b><span style="font-size:8pt;"><font face="Tahoma" color="#454045"> </font></span></p>
</td>
<td width="765" height="8" valign="top">
<p><span style="font-size:8pt;"><b><font face="Tahoma" color="#454045"><img src="images/circle03_darkblue_1.gif" width="6" height="10" border="0" align="middle"></font></b><font face="Tahoma" color="#454045"> </font><b><u><font face="Tahoma" color="#454045">หัวเรื่อง</font></u><font face="Tahoma" color="#454045"> : </font></b><font face="Tahoma" color="#454045"><%=objRs("booktitle")%></font></span></p>
</td>
</tr>
<tr>
<td width="938" height="25" valign="top" colspan="2">
<p><b><span style="font-size:8pt;"><font face="Tahoma" color="#454045"> </font></span></b><span style="font-size:8pt;"><b><font face="Tahoma" color="#454045"><img src="images/circle03_darkblue_1.gif" width="6" height="10" border="0" align="middle"></font></b></span><span style="font-size:8pt;"><font color="#454045"> </font><b><u><font face="Tahoma" color="#454045">ปีที่พิมพ์</font></u><font face="Tahoma" color="#454045"> : </font></b><font face="Tahoma" color="#454045"><%=objRs("bookyear")%></font><b><font color="#454045"> </font><u><font face="Tahoma" color="#454045">สถานที่พิมพ์</font></u><font face="Tahoma" color="#454045"> : </font></b><font face="Tahoma" color="#454045"><%=objRs("booklocalprint")%></font><b><font color="#454045"> </font><font face="Tahoma" color="#454045"> </font><u><font face="Tahoma" color="#454045">พิมพ์ครั้งที่</font></u><font face="Tahoma" color="#454045"> : </font></b><font face="Tahoma" color="#454045"><%=objRs("booknum")%></font></span><font face="Tahoma" color="#454045"><span style="font-size:8pt;"><b> </b></span></font></p>
<hr color="#009900" width="90%" align="left" style="border-style:solid;" size="1"> </td>
</tr>
</table>
</td>
</tr>
<%
If strRowColor = "#ffffff" Then strRowColor = "#ffffff" Else strRowColor = "#ffffff"
intRecord = intRecord + 1
objRs.MoveNext
Loop
%>
<tr>
<td colspan="2" width="977" height="9" valign="middle">
<ul>
<p align="left"><span style="font-size:8pt;"><font face="Tahoma" color="#FF6600"><img src="images/my_normal_post.gif" width="16" height="16" border="0" align="absmiddle"> </font><u><font face="Tahoma" color="blue">ผลการค้นหา</font></u><font face="Tahoma" color="blue"> ค้นพบ </font><u><font face="Tahoma" color="blue"><%=objRs.RecordCount%></font></u></span><span style="font-family:Arial,Helvetica,sans-serif; font-weight:normal; font-size:8pt; color:black; text-decoration:none;"><font face="Tahoma" color="blue"> </font></span><span style="font-size:8pt;"><font face="Tahoma" color="blue">รายการ</font></span></p>
</ul>
</td>
</tr>
<tr>
<td width="977" height="32" valign="middle" colspan="2" background="images/top.gif">
<p align="center"><%=Paging(intPage, objRs.PageCount, objRs.RecordCount)%></p>
</td>
</tr>
<tr>
<td align="center" colspan="2" width="977" height="6" valign="middle">
<p><span style="font-size:8pt;"><font color="#333333"><%end if%></font></span></p>
</td>
</tr>
</table>
</td>
</tr>
<%End If%>
</table><table cellpadding="0" cellspacing="0">
<tr>
<td width="984" height="19">
<p align="center"><span style="font-size:8pt;"><font face="Tahoma" color="#6699FF"><img src="images/logo.gif" width="66" height="38" border="0" align="absmiddle"> ระบบสืบค้นข้อมูลหนังสือ ( Web OPEC ) UPC Libary 2005 เวอร์ชั่น 1.6 Tell : 0-4815-0644 , 0-5541-3670 Email : [email protected] </font><font face="Tahoma" color="gray"><br></font></span><span style="font-size:8pt;"><font face="Tahoma" color="gray"><br></font></span></p>
</td>
</tr>
</table>
<p align="center"> </p>
</body>
</html>
<%
'Object cleanup
If IsObject(objRs) Then
If Not objRs Is Nothing Then
If objRs.State = adStateOpen Then objRs.Close
Set objRs = Nothing
End If
End If
If IsObject(objCn) Then
If Not objCn Is Nothing Then
If objCn.State = adStateOpen Then objCn.Close
Set objCn = Nothing
End If
End If
%>
เป็นโค้ดการค้นหาหนังสือในระบบห้องสมุด โค้ดทั้งหมดจะอยู่ในโฟลเดอร์ C:\Inetpub\wwwroot\library รูปภาพก็อยู่ในโฟล์เดอร์ C:\Inetpub\wwwroot\library\image ไฟล์หลักก็อยู่ใน C:\Inetpub\wwwroot\library\library.asp และฐานข้อมูลก็อยู่ใน C:\Inetpub\wwwroot\library\upcbook.mdb คือผมทำการค้นหาไม่ได้ครับ เรียนเว็บมาสเตอร์และท่านผู้รู้ทุกท่าน ช่วยแนะนำด้วยนะครับ ขอขอบพระคุณมากๆ ครับ 
Tag : - - - -
|
|
 |
 |
 |
 |
Date :
26 ธ.ค. 2548 08:54:31 |
By :
ปราชญ์ |
View :
2200 |
Reply :
1 |
|
 |
 |
 |
 |
|
|
|
 |