Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C#
  4. Update Table

Update Table

Scheduled Pinned Locked Moved C#
htmldatabasequestionannouncement
11 Posts 4 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • K Offline
    K Offline
    kibromg
    wrote on last edited by
    #1

    Hi All, I have the follwoing data on html page : "NEW","939192","0005","0108500301000000001" "NEW","939192","0005","0208500301000000003" How can i read the above comma separated data on a page and Populate my Table in Sql 2005. Thank you in Advance.

    S E P 3 Replies Last reply
    0
    • K kibromg

      Hi All, I have the follwoing data on html page : "NEW","939192","0005","0108500301000000001" "NEW","939192","0005","0208500301000000003" How can i read the above comma separated data on a page and Populate my Table in Sql 2005. Thank you in Advance.

      S Offline
      S Offline
      ScottM1
      wrote on last edited by
      #2

      Have you tried DTS?

      K 1 Reply Last reply
      0
      • S ScottM1

        Have you tried DTS?

        K Offline
        K Offline
        kibromg
        wrote on last edited by
        #3

        Thank you so much.Is there not a way of wrting a code to do that?

        1 Reply Last reply
        0
        • K kibromg

          Hi All, I have the follwoing data on html page : "NEW","939192","0005","0108500301000000001" "NEW","939192","0005","0208500301000000003" How can i read the above comma separated data on a page and Populate my Table in Sql 2005. Thank you in Advance.

          E Offline
          E Offline
          Ennis Ray Lynch Jr
          wrote on last edited by
          #4

          That is usually how I insert into SQL. The CSV data can be split using the string.split method and if you parametrize the queries you will avoid SQL injection but still be susceptible to spammers so you will need to HTML encode any input.

          Need custom software developed? I do C# development and consulting all over the United States. A man said to the universe: "Sir I exist!" "However," replied the universe, "The fact has not created in me A sense of obligation." --Stephen Crane

          K 2 Replies Last reply
          0
          • E Ennis Ray Lynch Jr

            That is usually how I insert into SQL. The CSV data can be split using the string.split method and if you parametrize the queries you will avoid SQL injection but still be susceptible to spammers so you will need to HTML encode any input.

            Need custom software developed? I do C# development and consulting all over the United States. A man said to the universe: "Sir I exist!" "However," replied the universe, "The fact has not created in me A sense of obligation." --Stephen Crane

            K Offline
            K Offline
            kibromg
            wrote on last edited by
            #5

            The problem is its not a csv file .The data is posted on a browser. How could i read data on a browser? Many thanks,

            E 1 Reply Last reply
            0
            • K kibromg

              The problem is its not a csv file .The data is posted on a browser. How could i read data on a browser? Many thanks,

              E Offline
              E Offline
              Ennis Ray Lynch Jr
              wrote on last edited by
              #6

              It is fairly difficult concept described in the "Beginning ASP.NET 3.5: In C# and VB" book published by Wrox in Chapters:5, 9, 11, and 12.

              Need custom software developed? I do C# development and consulting all over the United States. A man said to the universe: "Sir I exist!" "However," replied the universe, "The fact has not created in me A sense of obligation." --Stephen Crane

              1 Reply Last reply
              0
              • E Ennis Ray Lynch Jr

                That is usually how I insert into SQL. The CSV data can be split using the string.split method and if you parametrize the queries you will avoid SQL injection but still be susceptible to spammers so you will need to HTML encode any input.

                Need custom software developed? I do C# development and consulting all over the United States. A man said to the universe: "Sir I exist!" "However," replied the universe, "The fact has not created in me A sense of obligation." --Stephen Crane

                K Offline
                K Offline
                kibromg
                wrote on last edited by
                #7

                Thank you so much.Can you please give me a little more info on how to do that? Your help is much appreciated. Many thanks

                1 Reply Last reply
                0
                • K kibromg

                  Hi All, I have the follwoing data on html page : "NEW","939192","0005","0108500301000000001" "NEW","939192","0005","0208500301000000003" How can i read the above comma separated data on a page and Populate my Table in Sql 2005. Thank you in Advance.

                  P Offline
                  P Offline
                  PIEBALDconsult
                  wrote on last edited by
                  #8

                  Dunno, depends on how the information is presented on the page. One such page I scrape for data has the data I want in a table. The code I use to get the page is:

                  System.Net.HttpWebRequest req = (System.Net.HttpWebRequest) System.Net.HttpWebRequest.Create ( theurl ) ;

                  req.CachePolicy = new System.Net.Cache.RequestCachePolicy ( System.Net.Cache.RequestCacheLevel.NoCacheNoStore ) ;

                  using ( System.Net.HttpWebResponse rsp = (System.Net.HttpWebResponse) req.GetResponse() )
                  {
                  string res = ( new System.IO.StreamReader ( rsp.GetResponseStream() ) ).ReadToEnd() ;

                  // Then I use a Regular Expression to extract what I want
                  // and insert it to the database.
                  

                  }

                  I make no claims that this technique is "good", only that it does what I want for a rather unimportant Windows Service.

                  K 1 Reply Last reply
                  0
                  • P PIEBALDconsult

                    Dunno, depends on how the information is presented on the page. One such page I scrape for data has the data I want in a table. The code I use to get the page is:

                    System.Net.HttpWebRequest req = (System.Net.HttpWebRequest) System.Net.HttpWebRequest.Create ( theurl ) ;

                    req.CachePolicy = new System.Net.Cache.RequestCachePolicy ( System.Net.Cache.RequestCacheLevel.NoCacheNoStore ) ;

                    using ( System.Net.HttpWebResponse rsp = (System.Net.HttpWebResponse) req.GetResponse() )
                    {
                    string res = ( new System.IO.StreamReader ( rsp.GetResponseStream() ) ).ReadToEnd() ;

                    // Then I use a Regular Expression to extract what I want
                    // and insert it to the database.
                    

                    }

                    I make no claims that this technique is "good", only that it does what I want for a rather unimportant Windows Service.

                    K Offline
                    K Offline
                    kibromg
                    wrote on last edited by
                    #9

                    Thank you very much for your response.Its much appreciated.Each of the data are in a qutation and are separated by comma. Can you please give me a little tip on how to use the regular exression to trancate the value and assign it to the data field? Many thanks, Regards

                    P 1 Reply Last reply
                    0
                    • K kibromg

                      Thank you very much for your response.Its much appreciated.Each of the data are in a qutation and are separated by comma. Can you please give me a little tip on how to use the regular exression to trancate the value and assign it to the data field? Many thanks, Regards

                      P Offline
                      P Offline
                      PIEBALDconsult
                      wrote on last edited by
                      #10

                      Not without seeing the page. As mentioned, the data I scrape is in a table, so the page contains:

                      <td width="473" class="playlist">4:08 pm - The Beatles - Can't Buy Me Love<br>4:10 pm - The Doors - Break On Through<br>4:13 pm - Meat Loaf - Paradise By the Dashboard Light<br>4:21 pm - Klaatu - Mister Manson<br>4:25 pm - Bob Seger & The Silver Bullet Band - Long Twin Silver Line<br>4:29 pm - Eagles - Those Shoes<br></td>

                      and I use a Regular Expression to match <td width="473" class="playlist"> the data I want <br></td>; Then I split further on <br> and hyphen. You will need to find such a pattern in the page you're reading.

                      K 1 Reply Last reply
                      0
                      • P PIEBALDconsult

                        Not without seeing the page. As mentioned, the data I scrape is in a table, so the page contains:

                        <td width="473" class="playlist">4:08 pm - The Beatles - Can't Buy Me Love<br>4:10 pm - The Doors - Break On Through<br>4:13 pm - Meat Loaf - Paradise By the Dashboard Light<br>4:21 pm - Klaatu - Mister Manson<br>4:25 pm - Bob Seger & The Silver Bullet Band - Long Twin Silver Line<br>4:29 pm - Eagles - Those Shoes<br></td>

                        and I use a Regular Expression to match <td width="473" class="playlist"> the data I want <br></td>; Then I split further on <br> and hyphen. You will need to find such a pattern in the page you're reading.

                        K Offline
                        K Offline
                        kibromg
                        wrote on last edited by
                        #11

                        Thanks so much for your help. Here is the problem : I am trying to read data from a certain URl .Every time you run the Url with Different param it gives a result like the following. For instance runinng http://data.com/data.aspx?datefrom=20090601&dateto=20090621 will give a result of a comman separated data like the following. "john","wood","20090203" "terry",'brown",20090209" etc.. How will i read that and get it in to Sql Table?All i have to run is the above URL to generate the value. Please advice. Thank you in advance

                        1 Reply Last reply
                        0
                        Reply
                        • Reply as topic
                        Log in to reply
                        • Oldest to Newest
                        • Newest to Oldest
                        • Most Votes


                        • Login

                        • Don't have an account? Register

                        • Login or register to search.
                        • First post
                          Last post
                        0
                        • Categories
                        • Recent
                        • Tags
                        • Popular
                        • World
                        • Users
                        • Groups