Link to home
Start Free TrialLog in
Avatar of paulwhelan
paulwhelan

asked on

Auto insert and check if website is live?

Hi

I know that I can check if a website is 'live' by doing this in C#

HttpWebRequest webRequest = (HttpWebRequest)WebRequest.Create(websiteToRequest);
            webRequest.Timeout = 6000;
HttpWebResponse webResponse = (HttpWebResponse)webRequest.GetResponse();
string responseStream = webResponse.GetResponseHeader("Content-Length");

But does anyone know how to set up a scheduled task to check if a site is 'live'
and then insert into a table in my sql server database to say if its live or not?

Thanks              
Avatar of MikeWalsh
MikeWalsh
Flag of United States of America image

Well you could compile that code and execute it as a SQL Job...

Change your code to add a SQL Server connection string and insert the results into SQL.
Avatar of paulwhelan
paulwhelan

ASKER

BTW I just tried saving this

strConnection = "Data Source=PC024\\PAUL;Initial Catalog=paulstest;Integrated Security=True;";  
set objConn  =  CreateObject("ADODB.Connection")
objConn.Open strConnection
Set objRS    = CreateObject("ADODB.Recordset")

SQL = "INSERT INTO websitestatistics(id, checkeddate, didreply) " & _
      "VALUES ('1', '" & NOW() & "', 'n')"
set objRS = objConn.execute(SQL)

to a file 'scheduled.vbs'
and added a scheduled task
but when it ran it threw an error

windows script host
expected end of statement
"Well you could compile that code and execute it as a SQL Job...

Change your code to add a SQL Server connection string and insert the results into SQL."

How would I do that?

Thanks
ok I see it in Enetrprise Manager
Tools
Job Scheduling

Is it possible to check if the site is live and then do an insert to the database with a visual basic script?
If so how?

Thanks
ASKER CERTIFIED SOLUTION
Avatar of MikeWalsh
MikeWalsh
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial