lukechapman
Programmer
Hello,
I've got a problem with the following script:
*********************************************
<!-- #INCLUDE FILE="dsn.inc" -->
<%
Dim db 'the database connection object
Dim rs 'recordset, for select statements
Dim cmd 'a command object, for inserts, updates and deletes
Function DbInit
Set db = Server.CreateObject("ADODB.Connection"
db.Open strConnect
Set rs = Server.CreateObject ("ADODB.RecordSet" )
rs.ActiveConnection = db
rs.CursorType = adOpenForwardOnly
rs.LockType = adLockReadOnly
Set cmd = Server.CreateObject ("ADODB.Command" )
cmd.CommandType = adCmdText
Set cmd.ActiveConnection = db
End Function
Function DbUpdateNotice(aId, aTitle, aText, aContrib, aExpiryCode)
Dim sTitle, sText, sContrib
sTitle = replace(aTitle,"'","''"
sText = replace(aText,"'","''"
sContrib = replace(aContrib,"'","''"
cmd.CommandText = "update Notices " _
& " set Title='" & sTitle & "', Contributor='" & sContrib & "'," _
& " [Text]='" & sText & "',Expiry='" & aExpiryCode & "'" _
& " where Id=" & Request("aId"
cmd.Execute
End Function
Function DbInsertNotice(aGroupType, aGroupCode, aTitle, aText, aContrib, aExpiryCode)
Dim sTitle, sText, sContrib
sTitle = replace(aTitle,"'","''"
sText = replace(aText,"'","''"
sContrib = replace(aContrib,"'","''"
cmd.CommandText = "Insert into Notices" _
& "(GroupType,GroupCode,Title,[Text],Contributor,Expiry) " _
& " values('" & aGroupType & "','" & aGroupCode &"','" & sTitle & "','" & sText & "','" _
& sContrib & "','" & aExpiryCode & "')"
cmd.Execute
End Function
Function DbDeleteNotice(aId)
cmd.CommandText = "delete from Notices where Id=" & aId
cmd.Execute
End Function
Function DbDeleteNotices(aIdList)
cmd.CommandText = "delete from Notices where Id in (" & aIdList & ""
cmd.Execute
End Function
Function TimeStamp
TimeStamp = Year(Now()) & Month(Now()) & Day(Now()) & Hour(Now()) & Minute(Now()) & Second(Now())
End Function
Function FileExt(filename)
FileExt = Right(filename,len(filename)-instrRev(filename,"."+1)
End Function
Sub DbInsertAttachment(aClientFilename, aServerFilename, aDocTitle, aPupilId, aDocType, aFileSize, aAddedBy)
Dim sDocTitle,sql
sDocTitle = replace(aDocTitle,"'","''"
sql = "Insert into Attachments" _
& "(ServerFilename,ClientFilename,PupilId,DocTitle,DocType,FileSize,AddedBy) " _
& " values('" & aServerFilename & "','" & aClientFilename &"','" & aPupilId & "','" & sDocTitle & "','"_
& aDocType & "'," & aFileSize & ",'" & aAddedBy & "')"
cmd.CommandText = sql
cmd.Execute
End Sub
Sub DbMarkVisit(aUserId,aUserRole)
cmd.CommandText = "update Users set DateLastAccessed=Now() " _
& " where Id='" & aUserId & "' and Role='" & aUserRole & "'"
cmd.Execute
End Sub
Function DbClose
Set rs = Nothing
Set cmd = Nothing
Set db = Nothing
End Function
Function ExtractFilenameOnly(aFilename)
' NB. THIS IS DESIGNED TO WORK WITH DOS PATHS (BACKSLASHES) ONLY
Dim ipos, s
' 1. Find and remove any file extension
s = aFilename
ipos = InStrRev(s, "."
If ipos > 0 Then
s = Left(s, ipos-1)
End If
' 2. Find and remove any path
ipos = InStrRev(aFilename, "\"
If ipos > 0 Then
s = Right(s, Len(s)-ipos)
End If
ExtractFilenameOnly = s
End Function
%>
*****************************************************
The error I get is:
Microsoft JET Database Engine error '80004005'
Unspecified error
/common_asp.inc, line 10
******************************************************
I've checked the DB and all of columns are there and correct and I think the sql statements are correct. Any ideas?
I've got a problem with the following script:
*********************************************
<!-- #INCLUDE FILE="dsn.inc" -->
<%
Dim db 'the database connection object
Dim rs 'recordset, for select statements
Dim cmd 'a command object, for inserts, updates and deletes
Function DbInit
Set db = Server.CreateObject("ADODB.Connection"
db.Open strConnect
Set rs = Server.CreateObject ("ADODB.RecordSet" )
rs.ActiveConnection = db
rs.CursorType = adOpenForwardOnly
rs.LockType = adLockReadOnly
Set cmd = Server.CreateObject ("ADODB.Command" )
cmd.CommandType = adCmdText
Set cmd.ActiveConnection = db
End Function
Function DbUpdateNotice(aId, aTitle, aText, aContrib, aExpiryCode)
Dim sTitle, sText, sContrib
sTitle = replace(aTitle,"'","''"
sText = replace(aText,"'","''"
sContrib = replace(aContrib,"'","''"
cmd.CommandText = "update Notices " _
& " set Title='" & sTitle & "', Contributor='" & sContrib & "'," _
& " [Text]='" & sText & "',Expiry='" & aExpiryCode & "'" _
& " where Id=" & Request("aId"
cmd.Execute
End Function
Function DbInsertNotice(aGroupType, aGroupCode, aTitle, aText, aContrib, aExpiryCode)
Dim sTitle, sText, sContrib
sTitle = replace(aTitle,"'","''"
sText = replace(aText,"'","''"
sContrib = replace(aContrib,"'","''"
cmd.CommandText = "Insert into Notices" _
& "(GroupType,GroupCode,Title,[Text],Contributor,Expiry) " _
& " values('" & aGroupType & "','" & aGroupCode &"','" & sTitle & "','" & sText & "','" _
& sContrib & "','" & aExpiryCode & "')"
cmd.Execute
End Function
Function DbDeleteNotice(aId)
cmd.CommandText = "delete from Notices where Id=" & aId
cmd.Execute
End Function
Function DbDeleteNotices(aIdList)
cmd.CommandText = "delete from Notices where Id in (" & aIdList & ""
cmd.Execute
End Function
Function TimeStamp
TimeStamp = Year(Now()) & Month(Now()) & Day(Now()) & Hour(Now()) & Minute(Now()) & Second(Now())
End Function
Function FileExt(filename)
FileExt = Right(filename,len(filename)-instrRev(filename,"."+1)
End Function
Sub DbInsertAttachment(aClientFilename, aServerFilename, aDocTitle, aPupilId, aDocType, aFileSize, aAddedBy)
Dim sDocTitle,sql
sDocTitle = replace(aDocTitle,"'","''"
sql = "Insert into Attachments" _
& "(ServerFilename,ClientFilename,PupilId,DocTitle,DocType,FileSize,AddedBy) " _
& " values('" & aServerFilename & "','" & aClientFilename &"','" & aPupilId & "','" & sDocTitle & "','"_
& aDocType & "'," & aFileSize & ",'" & aAddedBy & "')"
cmd.CommandText = sql
cmd.Execute
End Sub
Sub DbMarkVisit(aUserId,aUserRole)
cmd.CommandText = "update Users set DateLastAccessed=Now() " _
& " where Id='" & aUserId & "' and Role='" & aUserRole & "'"
cmd.Execute
End Sub
Function DbClose
Set rs = Nothing
Set cmd = Nothing
Set db = Nothing
End Function
Function ExtractFilenameOnly(aFilename)
' NB. THIS IS DESIGNED TO WORK WITH DOS PATHS (BACKSLASHES) ONLY
Dim ipos, s
' 1. Find and remove any file extension
s = aFilename
ipos = InStrRev(s, "."
If ipos > 0 Then
s = Left(s, ipos-1)
End If
' 2. Find and remove any path
ipos = InStrRev(aFilename, "\"
If ipos > 0 Then
s = Right(s, Len(s)-ipos)
End If
ExtractFilenameOnly = s
End Function
%>
*****************************************************
The error I get is:
Microsoft JET Database Engine error '80004005'
Unspecified error
/common_asp.inc, line 10
******************************************************
I've checked the DB and all of columns are there and correct and I think the sql statements are correct. Any ideas?