I have some code (below). As you can see, I don't really know what I am doing. I've been hacking at bits of code that looks about right.
The idea is that this routine retrives the location of an rss feed from my blogroll then loads it to scan it for the latest posting date, then update my database with the latest date.
It does cycle through all the links in the recordset but the bit that is supposed to get the latest date, I dont think is anywhere near right.
I think the "For Each objItem In objitems" is probably wrong and for some reason it underlines "thedate" in the update query and says I cant use it because Ive used it before it has been assigned a value, which presumably means the xml scan is not setting the variable to anything. But it says that before I even exectute so I really don't know. Any ideas?
Thanks.
The idea is that this routine retrives the location of an rss feed from my blogroll then loads it to scan it for the latest posting date, then update my database with the latest date.
It does cycle through all the links in the recordset but the bit that is supposed to get the latest date, I dont think is anywhere near right.
I think the "For Each objItem In objitems" is probably wrong and for some reason it underlines "thedate" in the update query and says I cant use it because Ive used it before it has been assigned a value, which presumably means the xml scan is not setting the variable to anything. But it says that before I even exectute so I really don't know. Any ideas?
Thanks.
PHP:
Protected Sub Button2_Click(sender As Object, e As System.EventArgs) Handles Button2.Click
Dim connetionString As String
Dim connection As SqlConnection
Dim command As SqlCommand
Dim adapter As New SqlDataAdapter
Dim ds As New DataSet
Dim i As Integer
Dim cellcount As Integer
Dim objRoot As Object
Dim objitems As Object
Dim SQL As String = "select * from tbl_blogroll where rssloc is not null"
Dim thedate As String
Dim brid As Integer
Dim objXML As Object
connetionString = ConfigurationManager.ConnectionStrings("cerberusConnectionString").ConnectionString
connection = New SqlConnection(connetionString)
connection.Open()
command = New SqlCommand(SQL, connection)
adapter.SelectCommand = command
adapter.Fill(ds)
For i = 0 To ds.Tables(0).Rows.Count - 1
Dim rss As String = ds.Tables(0).Rows(i).Item(3)
Dim thefeed As String = rss
brid = ds.Tables(0).Rows(i).Item(0)
objXML = Server.CreateObject("MSXML2.DOMDocument.4.0")
objXML = Server.CreateObject("Microsoft.XMLDOM")
objXML.Async = False
objXML.SetProperty("ServerHTTPRequest", True)
objXML.ResolveExternals = True
objXML.ValidateOnParse = True
objXML.Load(thefeed)
cellcount = 0
If (objXML.parseError.errorCode = 0) Then
objRoot = objXML.documentElement
objitems = objRoot.getElementsByTagName("item")
For Each objItem In objitems
On Error Resume Next
thedate = objItem.selectSingleNode("pubDate").Text
Next
End If
objXML = Nothing
Using Conn As New SqlConnection(ConfigurationManager.ConnectionStrings("cerberusConnectionString").ConnectionString)
Dim sql1 As String = "update tbl_blogroll set Lupdate='" + thedate + "' where brid=" + brid
Dim myCommand1 As New SqlCommand(sql1, Conn)
myCommand1.ExecuteNonQuery()
End Using
Next i
adapter.Dispose()
command.Dispose()
connection.Close()
Response.Redirect("Default.aspx")
End Sub