I have a page right now that functions 100%, it updates a database , based on an id sent via querystring. Now, I am wanting to make this function perform for EVERY row in the database and without being sent a querystring.
Dim amzRepeater As DataRowView = e.Item.DataItem
Dim myId As String = Request.QueryString("Id")
Dim amzUrl As String = amzRepeater.Row("AmazonUrl")
amazonURL.Value = amzUrl
'''''''''''''''''''''''''''''''''''''''''''''''''''''''
Dim aHtml As New HtmlWeb
Dim aDoc As HtmlDocument = aHtml.Load(amazonURL.Value)
Dim aNode As HtmlAgilityPack.HtmlNode
aNode = aDoc.DocumentNode.SelectSingleNode("//div[@id='olpDivId']/span[2]")
Dim UsedPrice As String = aNode.InnerText
Dim i As Integer = UsedPrice.IndexOf("$")
UsedPrice = UsedPrice.Substring(i + 1)
Dim connStr As String = ConfigurationManager.ConnectionStrings("arprimaryConnectionString").ConnectionString
Dim con As New SqlConnection(connStr)
Dim cmd As New SqlCommand("UPDATE Amazon SET AmazonUsedPrice = @AmazonUsedPrice, LastUpdated = @LastUpdated WHERE (id = @id)", con)
cmd.Parameters.AddWithValue("@AmazonUsedPrice", UsedPrice)
cmd.Parameters.AddWithValue("@LastUpdated", DateTime.Now.ToString)
cmd.Parameters.AddWithValue("@Id", myId)
Using con
con.Open()
cmd.ExecuteNonQuery()
End Using
MsgBox("Update Sucesfull.")