Forums
This topic is locked
updating field automatically
Posted 28 May 2003 19:44:13
1
has voted
28 May 2003 19:44:13 Dave Clarke posted:
HII have a page that sends out reminders by email, it loops through a recordset and sends a reminder to everyone in that recordset.
Is it possible to put some update code within the loop so that it updates a field to show that a reminder has been sent, so that it doesnt get sent again?
Something like this perhaps?
<b><%
set Command1 = Server.CreateObject("ADODB.Command"

Command1.ActiveConnection = MM_connmessages2_STRING
Command1.CommandText = "UPDATE accessgroups SET sent 'Yes'"
Command1.CommandType = 1
Command1.CommandTimeout = 0
Command1.Prepared = true
Command1.Execute()
%></b>
Thanks
Dave
ASP|VBScript|IIS5.1|Access|WinXPPro & WinXPHome
Edited by - Davecl on 28 May 2003 19:47:43
Replies
Replied 28 May 2003 20:13:10
28 May 2003 20:13:10 Dave Clarke replied:
Hi, me again
Just realised that the above code would set ALL the records to 'Yes', so maybe this would be better.
<b><%
set Command1 = Server.CreateObject("ADODB.Command"
Command1.ActiveConnection = MM_connmessages2_STRING
Command1.CommandText = "UPDATE accessgroups SET fldsent = 'Yes' WHERE fldusername = username"
Command1.CommandType = 1
Command1.CommandTimeout = 0
Command1.Prepared = true
Command1.Execute()
%></b>
would this work?
Thanks
Dave
ASP|VBScript|IIS5.1|Access|WinXPPro & WinXPHome
Just realised that the above code would set ALL the records to 'Yes', so maybe this would be better.
<b><%
set Command1 = Server.CreateObject("ADODB.Command"

Command1.ActiveConnection = MM_connmessages2_STRING
Command1.CommandText = "UPDATE accessgroups SET fldsent = 'Yes' WHERE fldusername = username"
Command1.CommandType = 1
Command1.CommandTimeout = 0
Command1.Prepared = true
Command1.Execute()
%></b>
would this work?
Thanks
Dave
ASP|VBScript|IIS5.1|Access|WinXPPro & WinXPHome
Replied 29 May 2003 14:18:28
29 May 2003 14:18:28 David Behan replied:
You're taking the right approach! I'd advise:
<%
set Command1 = Server.CreateObject("ADODB.Command"
Command1.ActiveConnection = MM_connmessages2_STRING
Command1.CommandText = "UPDATE accessgroups SET fldsent = 'Yes' WHERE <font color=red>fldid</font id=red> = <font color=red>userid</font id=red>"
Command1.CommandType = 1
Command1.CommandTimeout = 0
Command1.Prepared = true
Command1.Execute()
%>
I have come across a lot of problems when starting out with asp when filtering a database based on words, i.e. not getting the correct record back, not returning any records, etc. Since then, I always use the id field to reference an update such as this.
Cheeurs...
_________________________
WinXP : IIS 5.1 : StudioMX : ASP : VBScript
www.dynamic.ie
<%
set Command1 = Server.CreateObject("ADODB.Command"

Command1.ActiveConnection = MM_connmessages2_STRING
Command1.CommandText = "UPDATE accessgroups SET fldsent = 'Yes' WHERE <font color=red>fldid</font id=red> = <font color=red>userid</font id=red>"
Command1.CommandType = 1
Command1.CommandTimeout = 0
Command1.Prepared = true
Command1.Execute()
%>
I have come across a lot of problems when starting out with asp when filtering a database based on words, i.e. not getting the correct record back, not returning any records, etc. Since then, I always use the id field to reference an update such as this.
Cheeurs...
_________________________
WinXP : IIS 5.1 : StudioMX : ASP : VBScript
www.dynamic.ie
Replied 30 May 2003 07:32:29
30 May 2003 07:32:29 Dave Clarke replied:
Thanks Beano
I'll give it a go.
Dave
ASP|VBScript|IIS5.1|Access|WinXPPro & WinXPHome
I'll give it a go.
Dave
ASP|VBScript|IIS5.1|Access|WinXPPro & WinXPHome
Replied 30 May 2003 21:49:00
30 May 2003 21:49:00 Dave Clarke replied:
Hi
I've put the update command in the loop and everything seems ok , the email is sent and there are no errors BUT the field is not updated to show the mail has been sent.
This is the update code, where membid is a variable set like this <b>membid = rsetReminder.Fields.Item("fldMemberID"
.Value</b>
update code:
<b>set Command1 = Server.CreateObject("ADODB.Command"
Command1.ActiveConnection = MM_connmessages2_STRING
Command1.CommandText = " UPDATE accessgroups SET accessgroups.fldreminded = 'Yes' WHERE accessgroups.fldMemberID= membid "
Command1.CommandType = 1
Command1.CommandTimeout = 0
Command1.Prepared = true
Command1.Execute()</b>
Any ideas?
Dave
ASP|VBScript|IIS5.1|Access|WinXPPro & WinXPHome
Edited by - Davecl on 30 May 2003 22:28:01
I've put the update command in the loop and everything seems ok , the email is sent and there are no errors BUT the field is not updated to show the mail has been sent.
This is the update code, where membid is a variable set like this <b>membid = rsetReminder.Fields.Item("fldMemberID"

update code:
<b>set Command1 = Server.CreateObject("ADODB.Command"

Command1.ActiveConnection = MM_connmessages2_STRING
Command1.CommandText = " UPDATE accessgroups SET accessgroups.fldreminded = 'Yes' WHERE accessgroups.fldMemberID= membid "
Command1.CommandType = 1
Command1.CommandTimeout = 0
Command1.Prepared = true
Command1.Execute()</b>
Any ideas?
Dave
ASP|VBScript|IIS5.1|Access|WinXPPro & WinXPHome
Edited by - Davecl on 30 May 2003 22:28:01
Replied 31 May 2003 10:21:08
31 May 2003 10:21:08 Dave Clarke replied:
Hi
Sorted!!
It was cos membid is a variable, correct code is
<b>set Command1 = Server.CreateObject("ADODB.Command"
Command1.ActiveConnection = MM_connmessages2_STRING
Command1.CommandText = "UPDATE accessgroups SET accessgroups.fldreminded = 'Yes' WHERE accessgroups.fldMemberID =" & membid
Command1.CommandType = 1
Command1.CommandTimeout = 0
Command1.Prepared = true
Command1.Execute()</b>
ASP|VBScript|IIS5.1|Access|WinXPPro & WinXPHome
Sorted!!
It was cos membid is a variable, correct code is
<b>set Command1 = Server.CreateObject("ADODB.Command"

Command1.ActiveConnection = MM_connmessages2_STRING
Command1.CommandText = "UPDATE accessgroups SET accessgroups.fldreminded = 'Yes' WHERE accessgroups.fldMemberID =" & membid
Command1.CommandType = 1
Command1.CommandTimeout = 0
Command1.Prepared = true
Command1.Execute()</b>
ASP|VBScript|IIS5.1|Access|WinXPPro & WinXPHome