473,322 Members | 1,241 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,322 software developers and data experts.

How to insert Bulk data from Gridview to Database table

I have Bulk data ,just want to insert that data from Gridview to Database table how it possible?
I have done this way is it correct?
Expand|Select|Wrap|Line Numbers
  1. protected void btn_insert_Click(object sender, EventArgs e)
  2.  
  3.         {
  4.  
  5.             foreach (GridViewRow g1 in GridView1.Rows)
  6.  
  7.             {
  8.  
  9.                 SqlConnection con = new SqlConnection(connStr);
  10.  
  11.                 com = new SqlCommand("insert into student(sid,sname,smarks,saddress) values ('" + g1.Cells[0].Text + "','" + g1.Cells[1].Text + "','" + g1.Cells[2].Text + "','" + g1.Cells[3].Text + "')", con);
  12.  
  13.                 con.Open();
  14.  
  15.                 com.ExecuteNonQuery();
  16.  
  17.                 con.Close();
  18.  
  19. <!--[if !supportEmptyParas]--> <!--[endif]-->
  20.  
  21.             }
  22.  
  23.             Label1.Text = "Records inserted successfully";
  24.  
  25.         }
  26.  
  27.     }
  28.  
  29. }


Regards
Sree
May 8 '13 #1
0 2279

Sign in to post your reply or Sign up for a free account.

Similar topics

4
by: Ester | last post by:
I would like to read data from a database table row by row and execute some codes based on the data retrieved from each row. For example, there are 4 fields on a table called Image_Tbl. Those...
6
by: Tuong Do | last post by:
Hi, I am going to insert a large amount (200,000 records) of data into a table Is there a way that I can temporarily disable the log? so that the insertion run faster Thanks in advance
11
by: Hi5 | last post by:
Hi, I am new to access I usedto work in Oracle and Mysql. I am after a way that enables me to populate a database I designed in access with lots of data which can be sorted in excel sheets, ...
1
by: 4 | last post by:
I am having some trouble w/ a school project database that I am doing. The database is used for a ski rental shop. In the rental table I have various customers w/ rentals on different days. I have...
1
seshu
by: seshu | last post by:
Hi everybody This is seshu here i am struck with one point i want to get the data of one table ie table1 ofcourse not the whole table only two out of five columns and i want to...
2
by: YEW | last post by:
Hi, all I am new to ASP.NET. I am testing an example that inserts a record into an access database. But i have got an error when i browse the sample aspx page from IE 7. In the error the line...
3
by: Kunal Desale | last post by:
Hi, How to insert/update data in foxpro table field having datatype MEMO using Linked Server? I have written sql insert queries in which i have used linked server to insert data into foxpro...
0
by: Amar Nath | last post by:
i am using this code..it shows the error as bulk insert CSVTest1 from 'D:\1_attlog.txt' with (FIELDTERMINATOR=' ') { FIELDTERMINATOR=' ' ROWTERMINATOR='\N'...
1
by: sudha k | last post by:
how to bind data from database table to a dropdownlist nested in a gridview
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.