請問這ASP怎沒辦法與ACCESS 2010連接呢 我到底缺了哪些?
這是書中的ASP檔案 但第一次接觸ASP連結2010 ACCESS資料庫 也不知道書中的環境是如何設定的
使用電腦是WIN7 64位元的
ASP已開啟 上層路徑已變更為True 偵錯也都有開啟 簡易的HTTP錯誤訊息也開啟 啟用32位元應用程式也開啟了
權限也已開啟IUSR Autheticated Users這2個群組了
資料庫也有讀取跟修改的權限都有開啟
但在網頁上顯示是一片空白呢 在網路上能用的方法都用上了 就不知道是不是程式碼的問題了 但第一次接觸又不知道該怎修改
(在資料來源只有mdb檔的驅動程式 OFFiCE只有2010的 不知道是不是因為這個問題 但還是想先從程式碼看是否有遺漏)
可以的話 不要更換其他連結字串 這樣反而會更看不懂 拜託了
懇求幫解決
<%
'//資料庫檔案
Const MDBEile = "Project14.mdb" '//接收SalesID
strSalesID = Request.QueryString("SalesID") '//接收SalesName
strSalesName = Request.QueryString("SalesName") '//接收查詢月份
strMonth = Request.QueryString("sMonth")
'//======接收查詢動作 nData======
'// 1:取得指定月份業績
'// 2:取得指定業務員業績
'// 3:取得指定業務員在指定月份之營業額
'// 4:新增業務員
'// 5:傳回所有業務員
'// 6:傳回指定業務員之有業績之月份
'// 7:傳回有業績之月份
'//=======================================================
nData = Request.QueryString("nData") '//接收欲執行查詢異動等相關作業動作
ocPath = Server.mappath("Project14.mdb") '//取得完整資料庫路徑 ( 絕對路徑 )
nRSID = 1'//確認為第一筆 Recordset 資料
Select Case nData
Case "1" '//取得指定月份業績
SQL = "Select Sales.SalesName,Revenue.revenue from Sales, Revenue where Sales.SalesID = Revenue.SalesID and Revnue.Month ="& strMonth
ACCESSRecordSet vlRs,SQL,ocPath '//開啟資料庫並取回資料錄
DO while Not vlRs.EOF
'//利用","分開每一筆資料值同時利用";"業務員姓名與業績資料
if nRSID = 1 then
strResponse = vlRs(0) & ":" & vlRs(1)
else
strResponse = strResponse & "," & vlRs(0) & ":" & vlRs(1)
End if
nRSID = nRSID + 1
vlRs.MoveNext
Loop
Response.write strResponse '//回傳完整字串
Case "2" '//取得指定業務員業績
SQL = "Select * from Revenue where SalesID="& strSalesID & "Order by Month"
ACCESSRecordSet vlRs,SQL,ocPath
DO while Not vlRs.EOF
if nRSID = 1 then
strResponse = EngMonth(vlRs("Month")) & ":" & vlRs("Revenue")
else
strResponse = strResponse & "," & EngMonth(vlRs("Month")) & ":" & vlRs("Revenue")
End if
nRSID = nRSID + 1
vlRs.MoveNext
Loop
Response.write strResponse
Case "3" '// 3:取得指定業務員在指定月份之營業額
SQL = "Select * from Revenue where SalesID="& strSalesID & " and Month="& strMonth
ACCESSRecordSet vlRs,SQL,ocPath
DO while Not vlRs.EOF
if nRSID = 1 then
strResponse = vlRs("Revenue")
else
strResponse = strResponse & "," & vlRs("Revenue")
End if
nRSID = nRSID + 1
vlRs.MoveNext
Loop
Response.write strResponse
Case "4" '// 4:新增業務員
On Error Resume Next
SQL = "Insert into Sales(SalesID,SalesName) values("& strSalesID &";"& strSalesName &", )"
ACCESSExecute SQL,ocPath
'//若新增業務員成功則傳回"true"失敗則傳回 "fales"
IF Err.Number <> 0 then
Response.write "false"
else
Response.write "true"
end if
Case "5" '// 5:傳回所有業務員
SQL = "Select * from Sales"
ACCESSRecordSet vlRs,SQL,ocPath
DO while Not vlRs.EOF
if nRSID = 1 then
strResponse = vlRs("SalesID") & "." & vlRs("SalesName")
else
strResponse = strResponse & "," & vlRs("SalesID") & "." & vlRs("SalesName")
End if
nRSID = nRSID + 1
vlRs.MoveNext
Loop
Response.write strResponse
Case "6" '// 6:傳回指定業務員之有業績之月份
SQL = "Select Month from Revenue where SalesID="& strSalesID
ACCESSRecordSet vlRs,SQL,ocPath
DO while Not vlRs.EOF
if nRSID = 1 then
strResponse = vlRs("Month")
else
strResponse = strResponse & "," & vlRs("Month")
End if
nRSID = nRSID + 1
vlRs.MoveNext
Loop
Response.white strResponse
Case "7" '// 7:傳回有業績之月份
SQL = "Select distinct(Month) from Revenue Order by Month"
ACCESSRecordSet vlRs,SQL,ocPath
DO while Not vlRs.EOF
if nRSID = 1 then
strResponse = vlRs(0)
else
strResponse = strResponse & "," & vlRs(0)
End if
nRSID = nRSID + 1
vlRs.MoveNext
Loop
Response.write strResponse
End Select
'//子程式ACCESSExecute
'//cSql:預執行之SQL語法,ocpath:資料庫絕對路徑
Sub ACCESSExecute(cSql,ocPath)
set cConn = Server.CreateObject("ADODB.Connection")
mdbparam="driver={Microsoft Access Driver (*.mdb)}"
cConn.Open mdbparam & ";dbq=" & ocPath
cConn.Execute cSql
End sub
'//子程式ACCESSExecute
'//vlRs:資料錄名稱,csql:預執行之SQL語法,ocpath:資料庫絕對路徑
Sub ACCESSRecordSet(vlRs,cSql,ocPath)
On Error Resume Next
set cConn = Server.CreateObject("ADODB.Connection")
mdbparam="driver={Microsoft Access Driver (*.mdb)}"
cConn.Open mdbparam & ";dbq=" & ocPath
If Err.Number <> 0 Then
Response.write "[error]"
Response.end
End if
Set vlRs = Server.CreateObject("ADODB.Recordset")
vlRs.Open cSql, cConn, 1,3,1
End sub
'//功能函數EngMonth 主要為轉換數字月份為英文月份
Function EngMonth(strMonth)
Select Case strMonth
Case 1
EngMonth = "January"
Case 2
EngMonth = "February"
Case 3
EngMonth = "March"
Case 4
EngMonth = "April"
Case 5
EngMonth = "May"
Case 6
EngMonth = "June"
Case 7
EngMonth = "July"
Case 8
EngMonth = "Augest"
Case 9
EngMonth = "September"
Case 10
EngMonth = "October"
Case 11
EngMonth = "November"
Case 12
EngMonth = "December"
End Select
End Function
%>