This topic is locked

Table events problem

3/2/2006 11:33:11 AM
ASPRunnerPro General questions
Sunrise author

As soon as I add this code

Function BeforeEdit(dict, where)
' Parameters:

' dict - Scripting.Dictionary object.

' Each field on the Edit form represented as 'Field name'-'Field value' pair

' where - string with WHERE clause pointing to record to be edited
'********** Send email with old data record ************

' do not forget to setup email parameters like From, SMTP server etc

' on 'Security->User login settings' dialog
set rsOld = CreateObject("ADODB.Recordset")

email="test@test.com"

message=""

subject="Sample subject"
' modify the following SQL query to select fields you like to send

rsOld.Open "select * from " & strTableName & where, dbConnection

if not rsOld.eof then

for i=0 to rsOld.Fields.Count-1

if not IsBinaryField(rsOld.Fields(i)) then _

message = message & rsOld.Fields(i).Name & " : " & rsOld(rsOld.Fields(i).Name) & vbcrlf

next

rsOld.Close

end if

set rsOld = Nothing
sendmail email, subject, message
BeforeEdit = True
' set BeforeEdit to True if you like to proceed with editing this record

' set it to False in other case
End Function





I get this error message whe trying to update a record:

Error number -2147217900

Fehlerbeschreibung [Microsoft][ODBC SQL Server Driver][SQL Server]Line 1: Incorrect syntax near '.'.

URL /vfptest/ET_KAT_edit.asp

SQL Abfrage select [LogID], [Stuhl], [Baugruppe], [Artikelnummer], [Artikelbezeichnung], [Fehlerbeschreibung], [Name], [Datum], [Berabeitet], [Kommentar], [Status] From [dbo].[ET-KAT] where ([ET-KAT].[LogID]=1214)

Additional info Event: RetVal = BeforeEdit(dict, sWhere)

Sergey Kornilov admin 3/2/2006

There is a bug in sample code. See my changes in bold.

Function BeforeEdit(dict, where)

' Parameters:

' dict - Scripting.Dictionary object.

' Each field on the Edit form represented as 'Field name'-'Field value' pair

' where - string with WHERE clause pointing to record to be edited
'** Send email with old data record ****

' do not forget to setup email parameters like From, SMTP server etc

' on 'Security->User login settings' dialog
set rsOld = CreateObject("ADODB.Recordset")

email="test@test.com"

message=""

subject="Sample subject"
' modify the following SQL query to select fields you like to send

rsOld.Open "select * from " & strTableName & " where " & where, dbConnection

if not rsOld.eof then

for i=0 to rsOld.Fields.Count-1

if not IsBinaryField(rsOld.Fields(i)) then _

message = message & rsOld.Fields(i).Name & " : " & rsOld(rsOld.Fields(i).Name) & vbcrlf

next

rsOld.Close

end if

set rsOld = Nothing
sendmail email, subject, message
BeforeEdit = True
' set BeforeEdit to True if you like to proceed with editing this record

' set it to False in other case
End Function