 |
|
คือ ผมเขียน asp เชื่อมต่อกับ access โดย access link ฐานข้อมูลมาจาก excel ครับ
ซึ่งระบบนี้ใช้จริงในบริษัท โดยลักษณะการเขียนแล้วในตัวของ access จะมีการ SELECT ข้อมูล
เพื่อมาแสดง แล้วทำการเขียน asp เรียกใช้ข้อมูลจาก access ลักษณะนี้ครับ
set Recordset1 = Server.CreateObject("ADODB.Recordset")
Recordset1.ActiveConnection = MM_pcreport_STRING
Recordset1.Source = "SELECT sum(CountOfcomname) FROM sgiall"
แต่พอผม จะทำการแก้ไขข้อมูลการ SELECT ใหม่เพื่อแสดงผลข้อมูลใหม่ปรากฏว่า error แบบนี้ครับ
###########################################################
The page cannot be displayed
There is a problem with the page you are trying to reach and it cannot be displayed.
--------------------------------------------------------------------------------
Please try the following:
Click the Refresh button, or try again later.
Open the localhost home page, and then look for links to the information you want.
HTTP 500.100 - Internal Server Error - ASP error
Internet Information Services
--------------------------------------------------------------------------------
Technical Information (for support personnel)
Error Type:
Microsoft OLE DB Provider for ODBC Drivers (0x80004005)
[Microsoft][ODBC Microsoft Access Driver] The Microsoft Jet database engine cannot open the file '(unknown)'. It is already opened exclusively by another user, or you need permission to view its data.
/pc/sgilocation.asp, line 5
Browser Type:
Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1; InfoPath.2; .NET CLR 2.0.50727)
Page:
GET /pc/sgilocation.asp
Time:
19 มิถุนายน 2551, 17:51:09
More information:
Microsoft Support
###########################################################
######## แต่พอผม RESTART เครื่องใหม่แล้ว localhost ใหม่ปรากฏว่ารันได้##########
ซึ่งโค้ดจริงๆ เป็นแบบนี้ครับ
######################################
<%@LANGUAGE="VBSCRIPT"%>
<!--#include file="Connections/pcreport.asp" -->
<%
set Recordset1 = Server.CreateObject("ADODB.Recordset")
Recordset1.ActiveConnection = MM_pcreport_STRING
Recordset1.Source = "SELECT sum(CountOfcomname) FROM sgiall"
Recordset1.CursorType = 0
Recordset1.CursorLocation = 2
Recordset1.LockType = 3
Recordset1.Open()
Recordset1_numRows = 0
%>
<%
Dim Recordset7__MMColParam
Recordset7__MMColParam = "com41"
if (Request("MM_EmptyValue") <> "") then Recordset7__MMColParam = Request("MM_EmptyValue")
%>
<%
set Recordset7 = Server.CreateObject("ADODB.Recordset")
Recordset7.ActiveConnection = MM_pcreport_STRING
Recordset7.Source = "SELECT sum(CountOfcomname) FROM sgi_rent_buy WHERE comno LIKE '" + Replace(Recordset7__MMColParam, "'", "''") + "%'"
Recordset7.CursorType = 0
Recordset7.CursorLocation = 2
Recordset7.LockType = 3
Recordset7.Open()
Recordset7_numRows = 0
%>
<%
Dim Recordset8__MMColParam
Recordset8__MMColParam = "com51"
if (Request("MM_EmptyValue") <> "") then Recordset8__MMColParam = Request("MM_EmptyValue")
%>
<%
set Recordset8 = Server.CreateObject("ADODB.Recordset")
Recordset8.ActiveConnection = MM_pcreport_STRING
Recordset8.Source = "SELECT sum(CountOfcomname) FROM sgi_rent_buy WHERE comno LIKE '" + Replace(Recordset8__MMColParam, "'", "''") + "%'"
Recordset8.CursorType = 0
Recordset8.CursorLocation = 2
Recordset8.LockType = 3
Recordset8.Open()
Recordset8_numRows = 0
%>
<%
' *** Go To Record and Move To Record: create strings for maintaining URL and Form parameters
' create the list of parameters which should not be maintained
MM_removeList = "&index="
If (MM_paramName <> "") Then MM_removeList = MM_removeList & "&" & MM_paramName & "="
MM_keepURL="":MM_keepForm="":MM_keepBoth="":MM_keepNone=""
' add the URL parameters to the MM_keepURL string
For Each Item In Request.QueryString
NextItem = "&" & Item & "="
If (InStr(1,MM_removeList,NextItem,1) = 0) Then
MM_keepURL = MM_keepURL & NextItem & Server.URLencode(Request.QueryString(Item))
End If
Next
' add the Form variables to the MM_keepForm string
For Each Item In Request.Form
NextItem = "&" & Item & "="
If (InStr(1,MM_removeList,NextItem,1) = 0) Then
MM_keepForm = MM_keepForm & NextItem & Server.URLencode(Request.Form(Item))
End If
Next
' create the Form + URL string and remove the intial '&' from each of the strings
MM_keepBoth = MM_keepURL & MM_keepForm
if (MM_keepBoth <> "") Then MM_keepBoth = Right(MM_keepBoth, Len(MM_keepBoth) - 1)
if (MM_keepURL <> "") Then MM_keepURL = Right(MM_keepURL, Len(MM_keepURL) - 1)
if (MM_keepForm <> "") Then MM_keepForm = Right(MM_keepForm, Len(MM_keepForm) - 1)
' a utility function used for adding additional parameters to these strings
Function MM_joinChar(firstItem)
If (firstItem <> "") Then
MM_joinChar = "&"
Else
MM_joinChar = ""
End If
End Function
%>
<html>
<head>
<title>Untitled Page</title>
<meta http-equiv="Content-Type" content="text/html; charset=windows-874">
<style type="text/css">
<!--
body { margin: 0px 0px; padding: 0px 0px}
a:link { color: #005CA2; text-decoration: none}
a:visited { color: #005CA2; text-decoration: none}
a:active { color: #0099FF; text-decoration: underline}
a:hover { color: #0099FF; text-decoration: underline}
-->
</style>
</head>
<body background="image/bgsea.jpg">
<div align="center">
<p> </p>
<p><font face="Tahoma, Tahoma" size="5"><font color="#ff0033"><b>รายงานจำนวนเครื่องคอมทั้งหมด</b></font></font></p>
<table width="51%" border="1" bgcolor="#ffff00">
<tr bgcolor="#99ccff">
<td width="14%">
<div align="center"><font face="Tahoma, Tahoma" size="2"><font color="#006600"><b>สถานที่</b></font></font></div>
</td>
<td width="15%">
<div align="center"><font face="Tahoma, Tahoma" size="2"><font color="#006600"><b>เช่า</b></font></font></div>
</td>
<td width="15%">
<div align="center"><font face="Tahoma, Tahoma" size="2"><font color="#006600"><b>ซื้อ</b></font></font></div>
</td>
<td width="15%">
<div align="center"><font face="Tahoma, Tahoma" size="2"><font color="#006600"><b>รวม</b></font></font></div>
</td>
</tr>
<tr>
<td width="14%" align="center"><b>SGI</b></td>
<td width="15%" bgcolor="#ffffff">
<div align="center"><font face="Tahoma, Tahoma" size="2"><b><A HREF="rentsgi.asp?<%= MM_keepNone & MM_joinChar(MM_keepNone) & "Expr1000=" & Recordset7.Fields.Item("Expr1000").Value %>"><%=(Recordset7.Fields.Item("Expr1000").Value)%></A></b></font></div>
</td>
<td width="15%" bgcolor="#ffffff">
<div align="center"><font face="Tahoma, Tahoma" size="2"><b><A HREF="buysgi.asp?<%= MM_keepNone & MM_joinChar(MM_keepNone) & "Expr1000=" & Recordset8.Fields.Item("Expr1000").Value %>"><%=(Recordset8.Fields.Item("Expr1000").Value)%></A></b></font></div>
</td>
<td width="15%" bgcolor="#ffffff">
<div align="center"><font face="Tahoma, Tahoma" size="2"><b><A HREF="reportsgi.asp?<%= MM_keepNone & MM_joinChar(MM_keepNone) & "Expr1000=" & Recordset1.Fields.Item("Expr1000").Value %>"><%=(Recordset1.Fields.Item("Expr1000").Value)%></A></b></font></div>
</td>
</tr>
<tr>
</table>
<p><a href="menu_sgi.asp"><font face="Tahoma, Tahoma" size="3"><b>กลับสู่หน้าแรก</b></font></a></p>
<p> </p>
</div>
</body>
</html>
<%
Recordset1.Close()
%>
<%
Recordset2.Close()
%>
<%
Recordset3.Close()
%>
<%
Recordset4.Close()
%>
<%
Recordset5.Close()
%>
<%
Recordset6.Close()
%>
<%
Recordset7.Close()
%>
<%
Recordset8.Close()
%>
<%
Recordset9.Close()
%>
<%
Recordset10.Close()
%>
<%
Recordset11.Close()
%>
<%
Recordset12.Close()
%>
###########################3
โดยมีไฟล์Connect ชื่อว่า pcreport
<%
'FileName="Connection_odbc_conn_dsn.htm"
'Type="ADO"
'HTTP="false"
'Catalog=""
'Schema=""
MM_pcreport_STRING = "dsn=pcreport;"
%>
มันเป็นอย่างนี้เพราะอะไรอะครับ รบกวนท่านผู้รู้ช่วยชี่แนะด้วยนะครับ
จะเกี่ยวกับ iis หรือ odbc หรือป่าวไม่แน่ใจครับ
คืออยากให้งานเสร็จอะครับจะแก้ก็ทำไม่ได้แต่นิดหน่อยก็ error และครับ
ขอบคุณนะครับที่ช่วยแนะนำผม
Tag : - - - -
|
|
 |
 |
 |
 |
Date :
19 มิ.ย. 2551 17:55:25 |
By :
นาย PETER |
View :
1812 |
Reply :
1 |
|
 |
 |
 |
 |
|
|
|
 |