Click here to Skip to main content
15,895,656 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Dear all,

I have web pages with tabel formate data how i can extract the data to database using c#.net windows application. Please help me.
Posted
Updated 14-Feb-13 16:47pm
v2
Comments
José Amílcar Casimiro 14-Feb-13 6:45am    
Do you want to extract a html table data into a database access file?
Member 7993229 14-Feb-13 7:54am    
Yes.
José Amílcar Casimiro 14-Feb-13 9:56am    
Is your code that builds the html page or the table is part of another page?
Member 7993229 14-Feb-13 22:48pm    
i dont have any code for extracting data from HTML page. Please let me know the code.
José Amílcar Casimiro 15-Feb-13 5:01am    
Solution 2

Save the data using ADO.NET as per your table structure, e.g: row wise.

These will help:
MSDN: ADO.NET[^]
MSDN: Accessing Data with ADO.NET[^]
Simple ADO.NET Database Read, Insert, Update and Delete using C#.[^]
 
Share this answer
 
I recommend you the "Html Agility Pack".

You can found it in here.

Some example how to use it here.

Sample code:
C#
HtmlDocument doc = new HtmlDocument();
doc.LoadHtml(@"<html><body><p><table id=""foo""><tr><th>hello</th></tr><tr><td>world</td></tr></table></body></html>");
foreach (HtmlNode table in doc.DocumentNode.SelectNodes("//table")) {
    Console.WriteLine("Found: " + table.Id);
    foreach (HtmlNode row in table.SelectNodes("tr")) {
        Console.WriteLine("row");
        foreach (HtmlNode cell in row.SelectNodes("th|td")) {
            Console.WriteLine("cell: " + cell.InnerText);
        }
    }
}
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900