2013-10-24 29 views
0

我得到經典ASP網站進行更新。我面臨奇怪的問題。每當我插入或更新記錄它給我500(內部服務器)錯誤。我從服務器上刪除舊數據庫&上傳了我的數據庫,難道是這個問題?未知的錯誤,當更新或從經典ASP的MS Access數據庫中插入記錄

生成的查詢是正確的。我複製了在我的數據庫中執行的查詢&。它工作沒有任何錯誤。但在服務器上它不工作。請幫幫我。

當我使用gConn.Execute(str_Qry)它會導致錯誤。有任何想法嗎 ?

這我使用連接數據庫的文件是general.asp

<% 
    dim ConnectionString 
    ConnectionString ="Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & Server.MapPath("/Database/MyDB.mdb")   
    '*** Local Connection *** 
    'ConnectionString="Provider=SQLOLEDB.1;Persist Security Info=False;User ID=sa;Initial Catalog=TestDB;Data Source=(local)" 

    Set gCn = server.CreateObject("Adodb.Connection") 
    gCn.Open ConnectionString   
    Set Session("Conn") = gCn 
    Session.Timeout=600 
    Server.ScriptTimeout=2000 

    sub closeConnection 
     IF gConn.state=adStateOpen Then 
      gConn.Close 
      set gConn=nothing 
      set session("Conn")="" 
     End IF 
    End sub 

    strURL=Request.ServerVariables("SCRIPT_NAME") 
    strjj=split(strURL,"/") 
    if ubound(strjj)>1 then 
     strPage=strjj(ubound(strjj)) 
    else 
     strPage=Mid(strURL,2,Len(strURL)-1) 
    end if 
    strPage=LCase(strPage) 



    Function IsZilch(v) 
     IsZilch = True 

     If VarType(v) = 0 Or VarType(v) = 1 Then Exit Function 
     If IsNull(v) Then Exit Function 
     If (v & "") = "" Then Exit Function 

     IsZilch = False 
    End Function 

    Function SQLFix(s) 
     If IsZilch(s) Then SQLFix = "" : Exit Function 
     SQLFix = Trim(Replace(s, "'", "''")) 
    End Function 


    Sub RW(s) 
     Response.Write(s) 
    End Sub 
    Sub RWE(s) 
     Response.Write(s) 
     Response.End 
    End Sub 

    Sub RWjs(s) 
     Response.Write("<script language=javascript>" & s &"</script>") 
    End Sub 

    Function ConvDate(strDate, strFormat) 
    '================================ 
    'Following are the pattern for date formating 
    ' %m Month as a decimal no. 02 
    ' %b Abbreviated month name Feb 
    ' %B Full month name February 
    ' %d Day of the month 23 
    ' %j Day of the year 54 
    ' %y Year without century 98 
    ' %Y Year with century 1998 
    ' %w Weekday as integer 5 (0 is Sunday) 
    ' %a Abbreviated day name Fri 
    ' %A Weekday Name Friday 
    ' %I Hour in 12 hour format 12 
    ' %H Hour in 24 hour format 24 
    ' %M Minute as an integer 01 
    ' %S Second as an integer 55 
    ' %P AM/PM Indicator PM 
    ' %% Actual Percent sign %% 
    '================================ 
     Dim intPosItem 
     Dim intHourPart 
     Dim strHourPart 
     Dim strMinutePart 
     Dim strSecondPart 
     Dim strAMPM 

     If not IsDate(strDate) Then 
      ConvDate = strDate 
      Exit Function 
     End If 

     intPosItem = Instr(strFormat, "%m") 
     Do While intPosItem > 0 
      strFormat = Left(strFormat, intPosItem-1) & _ 
      DatePart("m",strDate) & _ 
      Right(strFormat, Len(strFormat) - (intPosItem + 1)) 
      intPosItem = Instr(strFormat, "%m") 
     Loop 

     intPosItem = Instr(strFormat, "%b") 
     Do While intPosItem > 0 
      strFormat = Left(strFormat, intPosItem-1) & _ 
      MonthName(DatePart("m",strDate),True) & _ 
      Right(strFormat, Len(strFormat) - (intPosItem + 1)) 
      intPosItem = Instr(strFormat, "%b") 
     Loop 

     intPosItem = Instr(strFormat, "%B") 
     Do While intPosItem > 0 
      strFormat = Left(strFormat, intPosItem-1) & _ 
      MonthName(DatePart("m",strDate),False) & _ 
      Right(strFormat, Len(strFormat) - (intPosItem + 1)) 
      intPosItem = Instr(strFormat, "%B") 
     Loop 

     intPosItem = Instr(strFormat, "%d") 
     Do While intPosItem > 0 
      strFormat = Left(strFormat, intPosItem-1) & _ 
      DatePart("d",strDate) & _ 
      Right(strFormat, Len(strFormat) - (intPosItem + 1)) 
      intPosItem = Instr(strFormat, "%d") 
     Loop 

     intPosItem = Instr(strFormat, "%j") 
     Do While intPosItem > 0 
      strFormat = Left(strFormat, intPosItem-1) & _ 
      DatePart("y",strDate) & _ 
      Right(strFormat, Len(strFormat) - (intPosItem + 1)) 
      intPosItem = Instr(strFormat, "%j") 
     Loop 

     intPosItem = Instr(strFormat, "%y") 
     Do While intPosItem > 0 
      strFormat = Left(strFormat, intPosItem-1) & _ 
      Right(DatePart("yyyy",strDate),2) & _ 
      Right(strFormat, Len(strFormat) - (intPosItem + 1)) 
      intPosItem = Instr(strFormat, "%y") 
     Loop 

     intPosItem = Instr(strFormat, "%Y") 
     Do While intPosItem > 0 
      strFormat = Left(strFormat, intPosItem-1) & _ 
      DatePart("yyyy",strDate) & _ 
      Right(strFormat, Len(strFormat) - (intPosItem + 1)) 
      intPosItem = Instr(strFormat, "%Y") 
     Loop 

     intPosItem = Instr(strFormat, "%w") 
     Do While intPosItem > 0 
      strFormat = Left(strFormat, intPosItem-1) & _ 
      DatePart("w",strDate,1) & _ 
      Right(strFormat, Len(strFormat) - (intPosItem + 1)) 
      intPosItem = Instr(strFormat, "%w") 
     Loop 

     intPosItem = Instr(strFormat, "%a") 
     Do While intPosItem > 0 
      strFormat = Left(strFormat, intPosItem-1) & _ 
      WeekDayName(DatePart("w",strDate,1),True) & _ 
      Right(strFormat, Len(strFormat) - (intPosItem + 1)) 
      intPosItem = Instr(strFormat, "%a") 
     Loop 

     intPosItem = Instr(strFormat, "%A") 
     Do While intPosItem > 0 
      strFormat = Left(strFormat, intPosItem-1) & _ 
      WeekDayName(DatePart("w",strDate,1),False) & _ 
      Right(strFormat, Len(strFormat) - (intPosItem + 1)) 
      intPosItem = Instr(strFormat, "%A") 
     Loop 

     intPosItem = Instr(strFormat, "%I") 
     Do While intPosItem > 0 
      intHourPart = DatePart("h",strDate) mod 12 
      if intHourPart = 0 then intHourPart = 12 
      strFormat = Left(strFormat, intPosItem-1) & _ 
      intHourPart & _ 
      Right(strFormat, Len(strFormat) - (intPosItem + 1)) 
      intPosItem = Instr(strFormat, "%I") 
     Loop 

     intPosItem = Instr(strFormat, "%H") 
     Do While intPosItem > 0 
      strHourPart = DatePart("h",strDate) 
      if strHourPart < 10 Then strHourPart = "0" & strHourPart 
      strFormat = Left(strFormat, intPosItem-1) & _ 
      strHourPart & _ 
      Right(strFormat, Len(strFormat) - (intPosItem + 1)) 
      intPosItem = Instr(strFormat, "%H") 
     Loop 

     intPosItem = Instr(strFormat, "%M") 
     Do While intPosItem > 0 
      strMinutePart = DatePart("n",strDate) 
      if strMinutePart < 10 then strMinutePart = "0" & strMinutePart 
      strFormat = Left(strFormat, intPosItem-1) & _ 
      strMinutePart & _ 
      Right(strFormat, Len(strFormat) - (intPosItem + 1)) 
      intPosItem = Instr(strFormat, "%M") 
     Loop 

     intPosItem = Instr(strFormat, "%S") 
     Do While intPosItem > 0 
      strSecondPart = DatePart("s",strDate) 
      if strSecondPart < 10 then strSecondPart = "0" & strSecondPart 
      strFormat = Left(strFormat, intPosItem-1) & _ 
      strSecondPart & _ 
      Right(strFormat, Len(strFormat) - (intPosItem + 1)) 
      intPosItem = Instr(strFormat, "%S") 
     Loop 

     intPosItem = Instr(strFormat, "%P") 
     Do While intPosItem > 0 
      if DatePart("h",strDate) >= 12 then 
      strAMPM = "PM" 
      Else 
      strAMPM = "AM" 
      End If 
      strFormat = Left(strFormat, intPosItem-1) & strAMPM & _ 
      Right(strFormat, Len(strFormat) - (intPosItem + 1)) 
      intPosItem = Instr(strFormat, "%P") 
     Loop 

     intPosItem = Instr(strFormat, "%%") 
     Do While intPosItem > 0 
      strFormat = Left(strFormat, intPosItem-1) & "%" & _ 
      Right(strFormat, Len(strFormat) - (intPosItem + 1)) 
      intPosItem = Instr(strFormat, "%%") 
     Loop 

     ConvDate = strFormat 

    End Function 

    Sub ASPEmailSendMail(sToAddress,sFromAddress,sFromName,sSubject,sBody,sAttachment) 
     Dim objAspEmail 
     Set objAspEmail = Server.CreateObject("Persits.MailSender") 
     objAspEmail.Host = "localhost"  'Out going SMTP mail server address 
     objAspEmail.From = sFromAddress  'Who the e-mail is from 

     If sFromName <> "" Then 
      objAspEmail.FromName = sFromName 
     End If 

     objAspEmail.AddAddress sToAddress 'Who the e-mail is sent to 
     objAspEmail.Subject = sSubject  'The subject of the e-mail 
     objAspEmail.IsHTML = true 
     objAspEmail.Body = sBody   'The main body of the e-mail 
     If sAttachment<>"" Then 
      'objAspEmail.AddAttachment sAttachment 'Attachment of the e-mail   
     End If 

     'Send the e-mail 

     If NOT sMailServer = "" Then objAspEmail.Send   
      Set objAspEmail = Nothing 
      'ASPEmailSendMail = True 
    End Sub 

    Sub CDOSendEmail(sName,sEmail,tEmail,sSubject,sHTMLMessage,sAttachment) 
     '============================================================= 
     '======== These constants can't be modified. ================= 
     '============================================================= 
     Const cdoSendUsingMethod = "http://schemas.microsoft.com/cdo/configuration/sendusing" 
     Const cdoSendUsingPort = 2 
     Const cdoSMTPServer  = "http://schemas.microsoft.com/cdo/configuration/smtpserver" 
     Const cdoSMTPServerPort = "http://schemas.microsoft.com/cdo/configuration/smtpserverport" 
     Const cdoSMTPConnectionTimeout = "http://schemas.microsoft.com/cdo/configuration/smtpconnectiontimeout" 
     Const cdoSMTPAuthenticate  = "http://schemas.microsoft.com/cdo/configuration/smtpauthenticate" 
     Const cdoBasic     = 1 
     Const cdoAnonymous    = 0 
     Const cdoSendUserName   = "http://schemas.microsoft.com/cdo/configuration/sendusername" 
     Const cdoSendPassword   = "http://schemas.microsoft.com/cdo/configuration/sendpassword" 

     '============================================================== 

     '============================================================== 
     '=============== Declare Variables ============================ 
     '============================================================== 
     Dim objConfig ' As CDO.Configuration 
     Dim objMessage ' As CDO.Message 
     Dim Fields  ' As ADODB.Fields 

     Dim sToName,sToEmail,sHTMLBody,sTextBody 

     '=============================================================== 
     '================= Set object properties for IIS SMTP ========== 
     '=============================================================== 

     Set objConfig = Server.CreateObject("CDO.Configuration") 
     Set Fields = objConfig.Fields 

     With Fields 
      .Item(cdoSendUsingMethod)  = cdoSendUsingPort 
      .Item(cdoSMTPServer)   = "mail.staffavailable.com" 
      .Item(cdoSMTPServerPort)  = 25 
      .Item(cdoSMTPConnectionTimeout) = 10 
     ' .Item(cdoSMTPAuthenticate)  = cdoBasic 
      .Item(cdoSMTPAuthenticate)  = cdoAnonymous 
     ' .Item(cdoSendUserName)   = "[email protected]" 
     ' .Item(cdoSendPassword)   = "samson" 
      .Update 
     End With 

     Set objMessage = Server.CreateObject("CDO.Message") 
     Set objMessage.Configuration = objConfig 

     sHTMLBody  = "<html><body>" & vbcrlf 
     sHTMLBody = sHTMLBody & sHTMLMessage 
     sHTMLBody = sHTMLBody & "</body></html>" 

     With objMessage 
      .To   = tEmail 
      .From  = sName & " <" & sEmail & ">" 
      .Subject = sSubject 
      .HTMLBody = sHTMLMessage 
      '.TextBody = sHTMLMessage 
      IF sAttachment<>"" Then 
       .AddAttachment sAttachment 
      End IF 
      .Send 
     End With 

     Set Fields = Nothing 
     Set objMessage = Nothing 
     Set objConfig = Nothing 
    End Sub 
%> 
+0

您需要在IE中關閉友好的錯誤消息,並確保IIS正在向瀏覽器發送詳細的錯誤信息,將500錯誤轉化爲有用的東西。 – AnonJr

回答

1

問題在我的評論之外,我敢打賭,如果錯誤只更換數據庫後啓動文件,它將會是權限問題和IUSER帳戶沒有對.mdb文件的寫入權限。

如果你可以用更詳細的錯誤信息更新你的問題,它會幫助我們以更少的猜測得到更好的答案。

+0

問題是,我沒有得到任何類型的錯誤消息,除了500 - 內部服務器錯誤! –

+0

目前我在Mac上,所以不能這樣做..我會在晚上做。 3小時後 –

相關問題