473,405 Members | 2,300 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,405 software developers and data experts.

Classic ASP schedule execution on server

Hi All,

I have a pure asp (Vbscript) page that manipulates data between MSAccess and
SQLServer2000. I'm trying to use the Scheduler app on the IIS server to run
this page nightly but there must be a better way of doing this.

How can I make my code in to an object and install it on the server and have
it schedule to run nightly?
Below is the code:

dim connectionstring, rs, db, Querystring

'This vbscript communicates with the helpstar database located locally at
'connectionstring = "provider=microsoft.jet.oledb.4.0;data
source=c:\Program
Files\FOGBUGZ\website\FogBugzDailyUploadfromHelpSt ar\HSW.MDB;persist
security info=false"
connectionstring = "provider=microsoft.jet.oledb.4.0;data source=
\\Devadp\cdrive\Inetpub\wwwroot\applications\helps tar\HSW.MDB"

'for the purpose of extracting opened request assigned to the Applications
queue.
'Once data is found, this script will insert them into Fogbugz under the
"From Helpstar" project (#8).
'If duplicate helpstar requests (identifed by their case#) are found, they
will not be re-inserted into Fogbugz.
'Otherwise new request will be inserted.
'In the Computer field in Fogbugz, helpstar request# are stored for
reference in order to link back to the original case

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

'Prerequsites:
' 1) The Helpstar database (HSW.MDB) must be local to this machine?
' 2) This script runs on a web page. Must have this script run nightly
perhaps on the server by executing this url?
'************************************************* **************************
*****************

'1. 'Open dataset to FogBogz to prep insert of formatted Data
Set Conn = Server.CreateObject("ADODB.Connection")
Conn.Open "FogBugZDataUpload","InsertUpdate","1234"
set db = Server.CreateObject("ADODB.Connection")
db.Open connectionstring
Set rs = Server.CreateObject("ADODB.Recordset")

'2. 'Which person is assigned to the project 'From Helpstar'?
SQL="Select ixPersonOwner from Project where ixProject=8"
Set RS4 = Conn.Execute(SQL)

'3. 'Get Recordset of All Closed Req (bugs) from Helpstar Access DB 'by
executing the MSAccess query listed in the 'QueryString above
AllOpenedReqForAppDev

Querystring = "SELECT tblServiceRequest.ID, tblServiceRequest.QueueID, "
Querystring=Querystring&" tblUser.EMailAddress, tblMemo.ID,
tblServiceRequest.Title, tblMemo.fldMemo,"
Querystring=Querystring&" tblServiceRequest.Status,
tblServiceRequest.TimeLogged, tblServiceRequest.TimeClosed"
Querystring=Querystring&" FROM (tblServiceRequest INNER JOIN tblMemo ON
tblServiceRequest.ID = tblMemo.RequestID)"
Querystring=Querystring&" INNER JOIN tblUser ON
tblServiceRequest.RequesterID = tblUser.ID"
Querystring=Querystring&" WHERE (((tblServiceRequest.QueueID)=36 Or
(tblServiceRequest.QueueID)=35"
Querystring=Querystring&" Or (tblServiceRequest.QueueID)=21 Or
(tblServiceRequest.QueueID)=531 Or"
Querystring=Querystring&" (tblServiceRequest.QueueID)=550) AND
((tblServiceRequest.TimeClosed)=#12/31/9999#))"
Querystring=Querystring&" ORDER BY tblServiceRequest.ID DESC ,
tblServiceRequest.TimeLogged DESC;"

rs.Open Querystring, db, 3, 3

'4. Insert one row of header data into the BUG table 'Response.Write
rs("fldMemo"):Response.end
do
idx=0
OpenCloseStatus=1 '0 for closed and 1 for opened
DTOPEN=rs("TimeLogged")
DtRsolved=null 'rs("TimeClosed")
DtClosed=null 'rs("TimeClosed")
Stitle=rs("Title")
ixproj=8
ixArea=20
ixPersonOpened=rs4("ixPersonOwner")
ixPersonAssigned=rs4("ixPersonOwner") 'Use 1 to signify CLOSED otherwise
use a valid ID
ixstatus=1 '1 for opened(active) and 2 for resolved(closed)
ixPriority=1
ixFixFor=1
sVersion=""
sComputer= "HELPSTAR #"& rs("tblServiceRequest.ID")
hrsOrigEst=0
hrsCurrEst=0
hrsElapsed=0
c=0
sCustomerEmail=""
sGPFID=""
ixMailBox=0
ixCategory=1 '1=bug
SbugDispacho=""

SQL="Insert into BUG values("'& Idx&","
SQL=SQL&OpenCloseStatus&",'"& DTOPEN &"','"& DtRsolved &"','"& DtClosed
&"',"
SQL=SQL&"'"&RemoveQuotes(Stitle)&"'," & ixproj &"," & ixArea &","
SQL=SQL&ixPersonOpened &","&ixPersonAssigned&","
SQL=SQL&ixstatus&","&ixPriority&"," & ixfixFor &",'"
SQL=SQL&sVersion&"','" & sComputer&"'," & hrsOrigEst &","
SQL=SQL&hrsCurrEst&","&hrsElapsed&","&c&",'"&sCust omerEmail&"','" &
sGPFID&"',"
SQL=SQL&ixMailBox&","&ixCategory&",'"&sbugDispacho &"'"
SQL=SQL&")"

'5. Double check to make sure you are not inserting a duplicate helpstar
request #
'This function call will return either a 0 for not already there or a 1
if the entry exists
X=AlReadyInFogbugz(rs("tblServiceRequest.ID"))

if x=0 then
Set RS2 = Conn.Execute(SQL)
'if err<>0 then response.write SQL:response.end
'SendNotifyMail rs4("ixPersonOwner")
end if

'Now get the BugIndex number for Fogbugz to insert in the next table. This
index is self generated
'within the BUG table everytime a new row is inserted. SQLServer keeps
track of this bug
SQL="Select ixbug from BUG where
substring(sComputer,11,(len(sComputer)))='" & mid(sComputer,11) &"'"
Set RS3 = Conn.Execute(SQL)' Insert in to FogBug.BUG table one row case
header

'6. Insert into the BUGEVENT table. This table can contain # of rows for
each bug event

if X=0 then
BUGID=rs("tblServiceRequest.ID")
do while rs("tblServiceRequest.ID")=BUGID or rs.eof
sFilename=""
ixBugEvent=0
ixBug=rs3("ixbug") 'BUGID
sVerb="Opened"
dt=DTOPEN 'now
sfileStatus=""
ixPerson=rs4("ixPersonOwner")

s=trim(RemoveQuotes(rs("fldMemo"))) &" From: "&rs("EMailAddress")
fmail=0
fExternal=0
sChanges=""
SQL="Insert into BUGEVENT values('"
SQL=SQL&sFilename&"',"& ixBug &",'"& sVerb &"','"& dt &"',"
SQL=SQL&"'"&sfileStatus&"'," & ixPerson &",'" & s &"',"
SQL=SQL&fmail &","&fExternal&",'" & sChanges&"'"
SQL=SQL&")"

Set RS2 = Conn.Execute(SQL) 'Insert into the FogBugz.BUGEVENT table
rs.movenext
loop
end if 'if duplicate not found
'Response.Write "HELLO":Response.end
rs.movenext
loop until RS.eof
response.write "COMPLETE "& NOW
'-------------------------------------------------
Function RemoveQuotes(Val)
'This function will replace double or single quotes with a single
'or double hash mark instead
err=0:on error resume next

Dim CleanValue,ChrVal

CleanValue=""
For I = 1 to len(VAL)
if mid(Val,I,1)=chr(39) or mid(val,I,1)=chr(34) then
Chrval="`"
else
Chrval= mid(Val,I,1)
end if
CleanValue=CleanValue & Chrval
Next

RemoveQuotes=CleanValue
End Function

'--------------------------------------------------
Function AlReadyInFogbugz(idx)
SQL1="Select * from BUG where sComputer='" & sComputer &"'"

Set RS0 = Conn.Execute(SQL1)' Insert in to FogBug.BUG table one row case
header
err=0:on error resume next

rs0.movefirst
x=rs0("ixbug")

if err=0 then
AlReadyInFogbugz=1
else
AlReadyInFogbugz=0
end if
End Function

'--------------------------------------------------
Sub SendNotifyMail(PersonID)
dim objEMail

err=0:on Error resume next
SQL1="Select * from Person where ixperson=" & PersonID &" and fnotify=1"

Set RS00 = Conn.Execute(SQL1)
rs00.movefirst
x=rs00("semail")
If err=0 then
'Ok to send mail
set objEMail = Server.CreateObject("cdonts.NewMail")
objEMail.To = trim(x)
objEMail.From = "test"
objEMail.subject = "Mail Subject"
objEMail.body = "Body text"
objEmail.BodyFormat = 0
objEmail.MailFormat = 0
response.write x:response.end
objEMail.send
set objEMail = nothing
end if
End Sub
Jul 19 '05 #1
1 3069
An answer was provided for you in the SQLServer Programming group. Use a SQL
Server job.
"JackV" <vi****@consumer.org> wrote in message
news:OY****************@TK2MSFTNGP11.phx.gbl...
Hi All,

I have a pure asp (Vbscript) page that manipulates data between MSAccess and SQLServer2000. I'm trying to use the Scheduler app on the IIS server to run this page nightly but there must be a better way of doing this.

How can I make my code in to an object and install it on the server and have it schedule to run nightly?
Below is the code:

dim connectionstring, rs, db, Querystring

'This vbscript communicates with the helpstar database located locally at
'connectionstring = "provider=microsoft.jet.oledb.4.0;data
source=c:\Program
Files\FOGBUGZ\website\FogBugzDailyUploadfromHelpSt ar\HSW.MDB;persist
security info=false"
connectionstring = "provider=microsoft.jet.oledb.4.0;data source=
\\Devadp\cdrive\Inetpub\wwwroot\applications\helps tar\HSW.MDB"

'for the purpose of extracting opened request assigned to the Applications queue.
'Once data is found, this script will insert them into Fogbugz under the
"From Helpstar" project (#8).
'If duplicate helpstar requests (identifed by their case#) are found, they will not be re-inserted into Fogbugz.
'Otherwise new request will be inserted.
'In the Computer field in Fogbugz, helpstar request# are stored for
reference in order to link back to the original case

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

'Prerequsites:
' 1) The Helpstar database (HSW.MDB) must be local to this machine?
' 2) This script runs on a web page. Must have this script run nightly
perhaps on the server by executing this url?
'************************************************* ************************** *****************

'1. 'Open dataset to FogBogz to prep insert of formatted Data
Set Conn = Server.CreateObject("ADODB.Connection")
Conn.Open "FogBugZDataUpload","InsertUpdate","1234"
set db = Server.CreateObject("ADODB.Connection")
db.Open connectionstring
Set rs = Server.CreateObject("ADODB.Recordset")

'2. 'Which person is assigned to the project 'From Helpstar'?
SQL="Select ixPersonOwner from Project where ixProject=8"
Set RS4 = Conn.Execute(SQL)

'3. 'Get Recordset of All Closed Req (bugs) from Helpstar Access DB 'by
executing the MSAccess query listed in the 'QueryString above
AllOpenedReqForAppDev

Querystring = "SELECT tblServiceRequest.ID, tblServiceRequest.QueueID, "
Querystring=Querystring&" tblUser.EMailAddress, tblMemo.ID,
tblServiceRequest.Title, tblMemo.fldMemo,"
Querystring=Querystring&" tblServiceRequest.Status,
tblServiceRequest.TimeLogged, tblServiceRequest.TimeClosed"
Querystring=Querystring&" FROM (tblServiceRequest INNER JOIN tblMemo ON
tblServiceRequest.ID = tblMemo.RequestID)"
Querystring=Querystring&" INNER JOIN tblUser ON
tblServiceRequest.RequesterID = tblUser.ID"
Querystring=Querystring&" WHERE (((tblServiceRequest.QueueID)=36 Or
(tblServiceRequest.QueueID)=35"
Querystring=Querystring&" Or (tblServiceRequest.QueueID)=21 Or
(tblServiceRequest.QueueID)=531 Or"
Querystring=Querystring&" (tblServiceRequest.QueueID)=550) AND
((tblServiceRequest.TimeClosed)=#12/31/9999#))"
Querystring=Querystring&" ORDER BY tblServiceRequest.ID DESC ,
tblServiceRequest.TimeLogged DESC;"

rs.Open Querystring, db, 3, 3

'4. Insert one row of header data into the BUG table 'Response.Write
rs("fldMemo"):Response.end
do
idx=0
OpenCloseStatus=1 '0 for closed and 1 for opened
DTOPEN=rs("TimeLogged")
DtRsolved=null 'rs("TimeClosed")
DtClosed=null 'rs("TimeClosed")
Stitle=rs("Title")
ixproj=8
ixArea=20
ixPersonOpened=rs4("ixPersonOwner")
ixPersonAssigned=rs4("ixPersonOwner") 'Use 1 to signify CLOSED otherwise use a valid ID
ixstatus=1 '1 for opened(active) and 2 for resolved(closed)
ixPriority=1
ixFixFor=1
sVersion=""
sComputer= "HELPSTAR #"& rs("tblServiceRequest.ID")
hrsOrigEst=0
hrsCurrEst=0
hrsElapsed=0
c=0
sCustomerEmail=""
sGPFID=""
ixMailBox=0
ixCategory=1 '1=bug
SbugDispacho=""

SQL="Insert into BUG values("'& Idx&","
SQL=SQL&OpenCloseStatus&",'"& DTOPEN &"','"& DtRsolved &"','"& DtClosed
&"',"
SQL=SQL&"'"&RemoveQuotes(Stitle)&"'," & ixproj &"," & ixArea &","
SQL=SQL&ixPersonOpened &","&ixPersonAssigned&","
SQL=SQL&ixstatus&","&ixPriority&"," & ixfixFor &",'"
SQL=SQL&sVersion&"','" & sComputer&"'," & hrsOrigEst &","
SQL=SQL&hrsCurrEst&","&hrsElapsed&","&c&",'"&sCust omerEmail&"','" &
sGPFID&"',"
SQL=SQL&ixMailBox&","&ixCategory&",'"&sbugDispacho &"'"
SQL=SQL&")"

'5. Double check to make sure you are not inserting a duplicate helpstar
request #
'This function call will return either a 0 for not already there or a 1
if the entry exists
X=AlReadyInFogbugz(rs("tblServiceRequest.ID"))

if x=0 then
Set RS2 = Conn.Execute(SQL)
'if err<>0 then response.write SQL:response.end
'SendNotifyMail rs4("ixPersonOwner")
end if

'Now get the BugIndex number for Fogbugz to insert in the next table. This index is self generated
'within the BUG table everytime a new row is inserted. SQLServer keeps
track of this bug
SQL="Select ixbug from BUG where
substring(sComputer,11,(len(sComputer)))='" & mid(sComputer,11) &"'"
Set RS3 = Conn.Execute(SQL)' Insert in to FogBug.BUG table one row case
header

'6. Insert into the BUGEVENT table. This table can contain # of rows for
each bug event

if X=0 then
BUGID=rs("tblServiceRequest.ID")
do while rs("tblServiceRequest.ID")=BUGID or rs.eof
sFilename=""
ixBugEvent=0
ixBug=rs3("ixbug") 'BUGID
sVerb="Opened"
dt=DTOPEN 'now
sfileStatus=""
ixPerson=rs4("ixPersonOwner")

s=trim(RemoveQuotes(rs("fldMemo"))) &" From: "&rs("EMailAddress")
fmail=0
fExternal=0
sChanges=""
SQL="Insert into BUGEVENT values('"
SQL=SQL&sFilename&"',"& ixBug &",'"& sVerb &"','"& dt &"',"
SQL=SQL&"'"&sfileStatus&"'," & ixPerson &",'" & s &"',"
SQL=SQL&fmail &","&fExternal&",'" & sChanges&"'"
SQL=SQL&")"

Set RS2 = Conn.Execute(SQL) 'Insert into the FogBugz.BUGEVENT table
rs.movenext
loop
end if 'if duplicate not found
'Response.Write "HELLO":Response.end
rs.movenext
loop until RS.eof
response.write "COMPLETE "& NOW
'-------------------------------------------------
Function RemoveQuotes(Val)
'This function will replace double or single quotes with a single
'or double hash mark instead
err=0:on error resume next

Dim CleanValue,ChrVal

CleanValue=""
For I = 1 to len(VAL)
if mid(Val,I,1)=chr(39) or mid(val,I,1)=chr(34) then
Chrval="`"
else
Chrval= mid(Val,I,1)
end if
CleanValue=CleanValue & Chrval
Next

RemoveQuotes=CleanValue
End Function

'--------------------------------------------------
Function AlReadyInFogbugz(idx)
SQL1="Select * from BUG where sComputer='" & sComputer &"'"

Set RS0 = Conn.Execute(SQL1)' Insert in to FogBug.BUG table one row case
header
err=0:on error resume next

rs0.movefirst
x=rs0("ixbug")

if err=0 then
AlReadyInFogbugz=1
else
AlReadyInFogbugz=0
end if
End Function

'--------------------------------------------------
Sub SendNotifyMail(PersonID)
dim objEMail

err=0:on Error resume next
SQL1="Select * from Person where ixperson=" & PersonID &" and fnotify=1"

Set RS00 = Conn.Execute(SQL1)
rs00.movefirst
x=rs00("semail")
If err=0 then
'Ok to send mail
set objEMail = Server.CreateObject("cdonts.NewMail")
objEMail.To = trim(x)
objEMail.From = "test"
objEMail.subject = "Mail Subject"
objEMail.body = "Body text"
objEmail.BodyFormat = 0
objEmail.MailFormat = 0
response.write x:response.end
objEMail.send
set objEMail = nothing
end if
End Sub

Jul 19 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

8
by: P. Glassel | last post by:
I'm having problems getting session timeouts to change programmaticlaly under IIS6.0. This is unchanged code that ran as expected under IIS5.0. Anyone else run into this problem? Thx.
18
by: Lorenzo Bolognini | last post by:
Hi all, i am an ASP developer with 1,5+ years experience. After sneaking around the ASP Classic world for a bit i became a bit dissatisfied of my ASP code practices so i'd like to have some...
0
by: Adisorn Ratanakovit | last post by:
When you set up a full-text catalog in SQL Server and you set up the population schedule, a job gets created and scheduled under SQL Server Agent. The problem I encountered recently is when I...
1
by: Manish Jain | last post by:
Platform : ASP.Net/C#, Sql Server 2000 (Web Project) ----------------------------------------------------------- I need to schedule some tasks like Alert Generation at say 0:00 hrs everyday. And...
4
by: Ranjit | last post by:
I'm new to sql server programing. Please help me to scedule a stored procedure to run every hour. Thnak you all.
23
by: pamelafluente | last post by:
Hi guys! I want to do a large number of scheduled task (say 80). Each task can be run at a certain time every given weekday. For instance at 10am and 5pm on each monday, etc. I would like to...
9
by: KenLee | last post by:
I made an application which includes classic asp page and asp.net page. when I tried to redirect from classic asp page to asp.net 2.0 page, it works under my local IIS directory. ex) <a...
2
by: rkershberg | last post by:
I have a schedule job that I would like to run on a MSDE database. The stored proc executes just fine if I run it manually. But trying to schedule it through the Enterprise Manager (or Management...
5
by: =?Utf-8?B?SmltIFJvZGdlcnM=?= | last post by:
My question is simple: How does one debug ASP Classic with Microsoft Visual Web Developer Express 2005 ("VWD")? Looming in the back of anyone's mind when you see a posting like this on any...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.