• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 205
  • Last Modified:

Post form automatic every hour at server

Hi,
is it possible to have a form posted automatic every hour at server? <form ... runat="server"> ...
/ jenmat
0
jenmat
Asked:
jenmat
  • 5
  • 4
  • 2
  • +3
1 Solution
 
peterxlaneCommented:
you could create a standalone VBS file and schedule it with Task Scheduler...
0
 
WMIFCommented:
i am interpretting this as a type of autosave feature for you users, is that correct?  if so, you would be able to do this with a technique coined as AJAX.  it uses javascript to process data on the client and request data from the server.  in this case, you would use javascript to read all the form values and post them to a page created on the server side to process the values.  read through this quick tutorial to get a sense of what AJAX is capable of.

http://blog.coderlab.us/rasmus-30-second-ajax-tutorial/
0
 
ullfindsmitCommented:
use the JAVASCRIPT's setTimeOut function

-Smit
0
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 
kevp75Commented:
the problem with WMIF's and ullfindsmit's solutions, is that client needs to load the page to be able to do that.  For an automated solution peterxlane has the right idea.
0
 
ullfindsmitCommented:
well than it would be a windows question rather than an ASP/WEB question

-Smit.
0
 
kevp75Commented:
true, however one can use vbscript in ASP, and use vbscript to do also run this task
0
 
peterxlaneCommented:
I think that you post your question based on what type of issue/problem you are having, but that doesn't necessarily mean that the solution will implement that technology.  People ask questions all the time that really end up being solved by JavaScript, or .Net, etc.

And just to add one more possibility to the list of options... I had issues with getting an account setup for the scheduled task (one where the password did not expire).  The solution I ended up using was to create a DTS package on a SQL server, and then write a VBScript in the package.  This was then easily scheduled as a SQL job that could run on a recurring basis, and could use SQL credentials rather than a windows login.  I like this method and the scheduled task methods because they will continue to run even if the server gets rebooted or browser windows are closed or you are not logged on to the server.
0
 
sybeCommented:
Agree with peterxlane that a package on SQL Server is the best solution. At least when you have SQL Server running. I have understood that Windows Task Scheduler can only schedule a job once a day. If you want a job done every hour, you'd need to create 24 tasks in Task Scheduler and you really want to avoid that.
0
 
peterxlaneCommented:
You can actually create a task that repeats every X minutes, but I have found that it is still not quite as reliable as SQL (in my experience).  What is nice about SQL is that you can add steps to your DTS package based on different conditions being met.  You can also have it write the results to the event log, etc.
0
 
WMIFCommented:
with such little body to the question, all we can do is guess.  this is why i explained how i interpretted the question when i read it.  we need the asker to respond to clarify his situation.
0
 
jenmatAuthor Commented:
Hi all,
i need to be able to create a scheduled http-post to post a XML that will update a page on a site. The best would be to run it from SQL server as all the data is already there. Unfortunately i´m not very good at VB and have no idea how to create the XML in a StoredProcedure.
Hints? / Jens
0
 
peterxlaneCommented:
Let me make sure I understand:

Your form will create an XML file from a database that will update a web page?  If that is correct, then you should just create a web page that creates the XML on the fly, and specify that web page as your source XML file rather than trying to manually recreate it on a recurring basis.  If that is not the case, then can you be more specific on the details?
0
 
jenmatAuthor Commented:
like this,
first the data from database needs to be structured in a XML file. Then the XML file needs to be http posted to another server to update a guide on the web.
0
 
peterxlaneCommented:
Step 1:
edit the following script (below) to create the XML from your database and then post to the correct URL, and test it on an ASP page.

Step 2
once step one is working, then either schedule the script with task scheduler or create a SQL job to run on a recurring basis.


<%
connStr = "connection string for your database"
MySQL = "SELECT story FROM News"

Set oConn = CreateObject("ADODB.Connection")
Set oRecordset = CreateObject("ADODB.Recordset")
oConn.Open(connStr)

strXMLData = "<?xml version='1.0' encoding='ISO-8859-1'?><news>"

oRecordset.Open MySQL, oConn
Do While Not oRecordset.EOF
      strXMLData = strXMLData &  "<story>" & oRecordset("story") & "</story>"
      oRecordset.MoveNext
Loop
oRecordset.Close
oConn.Close
strXMLData = strXMLData &  "</news>"





strURL = "URL that will receive the file"
Set oXML = CreateObject("MSXML2.ServerXMLHTTP")
oXML.Open "POST", strURL, False
oXML.SetRequestHeader "Content-Type","application/x-www-form-urlencoded"       
oXML.Send "file=" & strXMLData

If (oXML.readyState <> 4) Or (oXML.Status <> 200) Then
      oXML.Abort            
      Response.Write "ERROR"
Else
      Response.Write oXML.ResponseText
End If

Set oXML = Nothing
%>


0
 
jenmatAuthor Commented:
Hi again,
i get the following error when trying to post it:
---------------------------------
The XML page cannot be displayed
Cannot view XML input using style sheet. Please correct the error and then click the Refresh button, or try again later.


--------------------------------------------------------------------------------

Invalid at the top level of the document. Error processing resource 'http://www.partner.destinationspass.se/xmlpost.asp'. ...

You have not posted a XML
-----------------------------------------

When running this:
-----------------------
<%@ Language=VBScript %>
<%Option Explicit%>
<!--#INCLUDE Virtual="/DpLocalPartner/DpInclude/DbConn.asp" -->
<!--#INCLUDE Virtual="/DpLocalPartner/DpInclude/AdoVbs.asp" -->
<%
dim C1ID
if Session("C1ID") = "" then C1ID = 1 else C1ID = Session("C1ID")
Set cmdSp = Server.CreateObject("ADODB.Command")
cmdSp.ActiveConnection = DpDaCst
cmdSp.CommandText = "Dp_Adm_Select_MobileInfoToXml"
cmdSp.CommandType = 4
CmdSp.Parameters.Append CmdSp.CreateParameter("@C1ID", 3, 1,, C1ID)
CmdSp.Parameters.Append CmdSp.CreateParameter("@LID", 3, 1,, 1)
set RS = CmdSp.Execute
dim arrGuideJava: arrGuideJava = RS.GetRows()
RS.Close: set RS = nothing: set CmdSp = nothing
dim strXMLData
strXMLData = "<?xml version='1.0' encoding='ISO-8859-1'?>"
strXMLData = strXMLData & "<javaguide>"
strXMLData = strXMLData & "<guideId>105</guideId>"
strXMLData = strXMLData & "<username>jensmattisson</username>"
strXMLData = strXMLData & "<password>elsa7864</password>"

dim iLastCat: iLastCat = ""
dim iLastType: iLastType = ""
for j = lbound(arrGuideJava,1) to ubound(arrGuideJava,2)

if iLastType <> arrGuideJava(2,j) and j <> 0 then strXMLData = strXMLData & "</text></element>"

if iLastCat <> arrGuideJava(0,j) and j <> 0 then strXMLData = strXMLData & "</heading>"
if iLastCat <> arrGuideJava(0,j) then
strXMLData = strXMLData & "<heading>"
strXMLData = strXMLData &  "<title>" & arrGuideJava(0,j) & "</title>"
strXMLData = strXMLData &  "<description>" & arrGuideJava(0,j) & "</description>"
strXMLData = strXMLData &  "<date>" & replace(replace(replace(arrGuideJava(1,j),"-",""),":","")," ","") & "</date>"
end if

if iLastType <> arrGuideJava(2,j) then
strXMLData = strXMLData & "<element>"
strXMLData = strXMLData &  "<title>" & replace(arrGuideJava(2,j),"&","&amp;") & "</title>"
strXMLData = strXMLData &  "<date>" & replace(replace(replace(arrGuideJava(5,j),"-",""),":","")," ","") & "</date>"
strXmlData = strXmlData & "<text>"
end if

strXMLData = strXMLData & replace(arrGuideJava(4,j),"&","&amp;") & vbCrLf & vbCrLf

iLastCat = arrGuideJava(0,j)
iLastType = arrGuideJava(2,j)
if j = ubound(arrGuideJava,2) then strXMLData = strXMLData & "</text></element></heading>"
next
strXMLData = strXMLData & "</javaguide>"

'Response.ContentType = "text/xml"
'Response.Write strXMLData


dim strUrl
strURL = "http://www.quedro.se/jg_xml_update.php"
dim oXML
Set oXML = CreateObject("MSXML2.ServerXMLHTTP")
oXML.Open "POST", strURL, False
oXML.SetRequestHeader "Content-Type","application/x-www-form-urlencoded"      
oXML.Send "xml=" & strXMLData
If (oXML.readyState <> 4) Or (oXML.Status <> 200) Then
     oXML.Abort            
     Response.Write "ERROR"
Else
     Response.Write oXML.ResponseText
End If
Set oXML = Nothing
0
 
jenmatAuthor Commented:
..."You have not posted a XML" ... is a error from the server i post to. Something seems to happen with the strXMLData when it is posted.
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

  • 5
  • 4
  • 2
  • +3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now