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. Web Development
  3. ASP.NET
  4. Doubt regarding SqlCommand object

Doubt regarding SqlCommand object

Scheduled Pinned Locked Moved ASP.NET
question
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.
  • N Offline
    N Offline
    nagendrathecoder
    wrote on last edited by
    #1

    Hello all, I want to know, can we insert multiple records at the same time using any method of SqlCommand class? If this is possible then how can we achieve it? Thanks, Nagendra.

    M 1 Reply Last reply
    0
    • N nagendrathecoder

      Hello all, I want to know, can we insert multiple records at the same time using any method of SqlCommand class? If this is possible then how can we achieve it? Thanks, Nagendra.

      M Offline
      M Offline
      Manas Bhardwaj
      wrote on last edited by
      #2

      SQLCommand does not tackle this as it is only resposible for passing on the execution statement to the server. Here [^]is a nice article for doing this.

      Manas Bhardwaj Please remember to rate helpful or unhelpful answers, it lets us and people reading the forums know if our answers are any good.

      I 1 Reply Last reply
      0
      • M Manas Bhardwaj

        SQLCommand does not tackle this as it is only resposible for passing on the execution statement to the server. Here [^]is a nice article for doing this.

        Manas Bhardwaj Please remember to rate helpful or unhelpful answers, it lets us and people reading the forums know if our answers are any good.

        I Offline
        I Offline
        Inderjeet Kaur
        wrote on last edited by
        #3

        Hi You can use BatchUpdate for this try { Craete SQL COmmand Object cmd.CommandType = CommandType.StoredProcedure; cmd.UpdatedRowSource = UpdateRowSource.None; cmd.Parameters.Add("@Param1", SqlDbType.Int, 4, argDt.Columns[0].ColumnName); cmd.Parameters.Add("@Pram2", SqlDbType.Bit, 5, argDt.Columns[1].ColumnName); cmd.CommandTimeout = 0; SqlDataAdapter da = new SqlDataAdapter(); da.InsertCommand = cmd; da.UpdateBatchSize = 100; conn.Open(); int recordsInserted = da.Update(argDt); conn.Close(); }

        Inderjeet Kaur Sr. Software Engg

        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