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. inserting multiple rows at a time

inserting multiple rows at a time

Scheduled Pinned Locked Moved ASP.NET
helpdatabaseperformanceannouncement
2 Posts 2 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.
  • Y Offline
    Y Offline
    yuvachandra
    wrote on last edited by
    #1

    Hi all actually on my webpage am displaying some data on the datagrid row wise...as per the project requirement am exposing the data to be editable(displaying in the text boxex) by making use of the itemtempale ...and am keeping one button outside the datagird.and while cliking on the button i am updating the entire datagrid by accepting what ever the data is modified i.e by calling like foreach(DataGridItem itm in DataGrid1.Items) { string st,st1,st2; st=((Label)itm.Cells[0].FindControl("lblAccountId")).Text; st1=((TextBox)itm.Cells[1].FindControl("AccCode")).Text; st2=((TextBox)itm.Cells[2].FindControl("Descrip")).Text; dataAdapter=new SqlDataAdapter("update AccountCode set AccountCode='" + st1 + "',Description='" + st2 + "'where AccountId=" + st,con); dataAdapter.Fill(ds,"contentTable"); } Know what the problem is...there was somany records like (100+ in the database)..if i did like this,it took a database interaction to update each row ...i.e,for the single click it will take 100+ times of database interaction... bcz of performance resion i want to avoid these interactions...i want the updation to be done by making single interaction with the database(i.e i want to handle all the datagrid data and take the updation at single time)......Plz help me out ,,or let me have some articles related to this.... regards yuva

    L 1 Reply Last reply
    0
    • Y yuvachandra

      Hi all actually on my webpage am displaying some data on the datagrid row wise...as per the project requirement am exposing the data to be editable(displaying in the text boxex) by making use of the itemtempale ...and am keeping one button outside the datagird.and while cliking on the button i am updating the entire datagrid by accepting what ever the data is modified i.e by calling like foreach(DataGridItem itm in DataGrid1.Items) { string st,st1,st2; st=((Label)itm.Cells[0].FindControl("lblAccountId")).Text; st1=((TextBox)itm.Cells[1].FindControl("AccCode")).Text; st2=((TextBox)itm.Cells[2].FindControl("Descrip")).Text; dataAdapter=new SqlDataAdapter("update AccountCode set AccountCode='" + st1 + "',Description='" + st2 + "'where AccountId=" + st,con); dataAdapter.Fill(ds,"contentTable"); } Know what the problem is...there was somany records like (100+ in the database)..if i did like this,it took a database interaction to update each row ...i.e,for the single click it will take 100+ times of database interaction... bcz of performance resion i want to avoid these interactions...i want the updation to be done by making single interaction with the database(i.e i want to handle all the datagrid data and take the updation at single time)......Plz help me out ,,or let me have some articles related to this.... regards yuva

      L Offline
      L Offline
      Laxmikant Lad
      wrote on last edited by
      #2

      u can use command builder dim da as new sqldatadapter("select * from emp",cn) dim cmb as new sqlcommandbuilder(da) dim dt as new datatable da.fill(dt) dim dr as datarow() dim i as int = 0 while i < grid.items.count -1 dr = dt.select("AccountId=" & s1) if dr.length > 0 then dr(0).item("AccountCode") = s1 dr(1).item("Description") = s2 end if i +=1 end while da.update(dt)

      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