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. updating data

updating data

Scheduled Pinned Locked Moved C#
databasecsharpasp-netcomhelp
3 Posts 3 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.
  • S Offline
    S Offline
    sneha01
    wrote on last edited by
    #1

    :)Hi, I m working on ASP.net 2.0 with SQL 2005 as backend , how can i form a loop so that , for every row present in datatable, a stored procedure Should be executed and the output obtain should update each row from datatable in my original table in database . foreach (DataRow rows in dt.Rows) { SqlCommand SpCmd = new SqlCommand("Select * from Table "); SpCmd.Connection = MyConn; SpCmd.CommandType = System.Data.CommandType.StoredProcedure; SpCmd.CommandText = "usp_Calc_SP"; Com.ExecuteNonQuery(); } I hve tried using for each cell row in datatable . But i think my loop is not working fine Can anyone help me in this . Thanks in advance :doh:

    L G 2 Replies Last reply
    0
    • S sneha01

      :)Hi, I m working on ASP.net 2.0 with SQL 2005 as backend , how can i form a loop so that , for every row present in datatable, a stored procedure Should be executed and the output obtain should update each row from datatable in my original table in database . foreach (DataRow rows in dt.Rows) { SqlCommand SpCmd = new SqlCommand("Select * from Table "); SpCmd.Connection = MyConn; SpCmd.CommandType = System.Data.CommandType.StoredProcedure; SpCmd.CommandText = "usp_Calc_SP"; Com.ExecuteNonQuery(); } I hve tried using for each cell row in datatable . But i think my loop is not working fine Can anyone help me in this . Thanks in advance :doh:

      L Offline
      L Offline
      Lost User
      wrote on last edited by
      #2

      hi ... I think your code is fine but

      sneha01 wrote:

      Com.ExecuteNonQuery();

      ???? sorry for this , check what you wrote here Com

      I know nothing , I know nothing

      1 Reply Last reply
      0
      • S sneha01

        :)Hi, I m working on ASP.net 2.0 with SQL 2005 as backend , how can i form a loop so that , for every row present in datatable, a stored procedure Should be executed and the output obtain should update each row from datatable in my original table in database . foreach (DataRow rows in dt.Rows) { SqlCommand SpCmd = new SqlCommand("Select * from Table "); SpCmd.Connection = MyConn; SpCmd.CommandType = System.Data.CommandType.StoredProcedure; SpCmd.CommandText = "usp_Calc_SP"; Com.ExecuteNonQuery(); } I hve tried using for each cell row in datatable . But i think my loop is not working fine Can anyone help me in this . Thanks in advance :doh:

        G Offline
        G Offline
        ganti r
        wrote on last edited by
        #3

        SqlCommand SpCmd = new SqlCommand("Select * from Table "); this is may be wrong. When CommanType is StoredProcdure, you have to give the stor proc name: though u are setting CommandText later check it out. The culprit i feel is ExecuteNonQuery(). it should have been ExecuteQuery()

        rAm i Think, i Wait, i Fast -- Siddartha

        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