ucanmoruk
Member
- Joined
- Apr 8, 2019
- Messages
- 5
- Programming Experience
- Beginner
I'm building a bot that goes to the links and take the title to the database by gridview. But when I push the button, just the last link's title coming all the column on database. How do I do this separately for each line?
I ay using Visual Studio, Windows Forms and Devexpress
I ay using Visual Studio, Windows Forms and Devexpress
The sum of button code:
for (int i = 0; i < gridView1.RowCount; i++)
{
string kaynak = gridView1.GetRowCellValue(i, colKaynak_Link).ToString();
urlal(kaynak, "//*[@id='cph1_lblKabulTar']", gridView1);
}
And the void urlal codes ::
public void urlal(string Url, string xpath, DevExpress.XtraGrid.Views.Grid.GridView Control)
url = new Uri(Url);
WebClient client = new WebClient();
client.Encoding = Encoding.UTF8;
html = client.DownloadString(url);
HtmlAgilityPack.HtmlDocument doc = new HtmlAgilityPack.HtmlDocument();
doc.LoadHtml(html);
for (int i = 0; i < gridView1.RowCount; i++)
{
int id = Convert.ToInt32(gridView1.GetRowCellValue(i, colDoküman_id));
baglanti.Open();
SqlCommand guncelle = new SqlCommand("Update dokuman set Kontrol_Tarihi=@s2 WHERE Doküman_id = @dokumanId", baglanti);
guncelle.Parameters.AddWithValue("s2", doc.DocumentNode.SelectSingleNode(xpath).InnerText);
guncelle.Parameters.AddWithValue("dokumanId", id);
guncelle.ExecuteNonQuery();
baglanti.Close();
}