我有一个经典ASP 网站要更新。我面临着奇怪的问题。每当我插入或更新记录时,它都会为我提供 500(内部服务器)错误 。我从服务器上删除了旧数据库&上传了我的数据库,这可能是问题吗?
生成的查询是正确的。我复制了查询&在我的数据库中执行。它没有任何错误。但是在服务器上它不起作用。请帮帮我。
当我使用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) = "dbarry@Concierge"
' .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 :(得分:1)
除了我的评论中的问题,我愿意打赌,如果错误仅在更换数据库文件后才开始,那么它将成为许可问题且IUSER帐户不具备写入.mdb文件的访问权限。
如果您可以使用更详细的错误消息更新您的问题,那么可以帮助我们以更少的猜测为您提供更好的答案。