Insert the records from excel cell to database

Uploading: InsertQuery.PNG… All,

I got a situation.
I have some data in an excel sheet in a particular format (refer the attachment) and i want to insert the same record into a database, and the format of insertion is mentioned below

Eg: I got say 20 records in an excel and the pattern is like (A1,A2,A3,A4 and so on),

I want to insert the first 4 four records in a SQL query like (insert into xyz values (A1,A2,A3,A4)
next insertion would be (insert into xyz values A5,A6,A7,A8) and so on

i.e. i want to execute the query with 4 records each time, till it ends

Refer the screen shot for referece

Please suggest

Hi @Ram0803,

Pls find the solution for your requirement.

@Pls use your db connection i have removed my coooon (31.8 KB) .

Omkar P

1 Like

Hi @Ram0803,

Your core logic is
for(int i=0; i< DT.Count() ; i++)

phonenumber = row.Table.Rows(i).Item(0).ToString
Bill number = row.Table.Rows(i+1).Item(0).ToString
Monthly rentals = row.Table.Rows(i+2).Item(0).ToString
Usage = row.Table.Rows(i+3).Item(0).ToString
i = i+3;
Omkar P


Thanks for this bro, i will try and revert…

Good Day :grinning:



Wonderful bro :v:


This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.