Click here to Skip to main content
15,890,438 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I wrote a condition in c# while exporting the data from excel sheet

OleDbDataAdapter ExcelAdapter = new OleDbDataAdapter("SELECT * FROM " + SpreadSheetName + " where [Serial Number] <>null ", ExcelConnection);

When I tried to import 1000 lines its only inserting 500 serials items n conditions fails when it starts with "RIUYOI78589649" series.

Excel Data Serial Number 389423576528635 . .//upto 5000 RIUYOI78589649//serial no 501 . . .1000

If I imported them individually from different excel sheets everything is working as expected

What I have tried:

Case 1: I tried to export data serial no starts from RIUYOI78589649 and followed by 389423576528635 in this case its working fine
Posted
Updated 16-Mar-18 12:10pm
Comments
j snooze 16-Mar-18 17:36pm    
You haven't said anything about your setup or database. We could only guess like you, but you know more than us. Is the data field numeric only? or does it have a character limit? What is the error you are getting when it stops if any? what happens when you debug it it? Good info to provide for people who have absolutely no idea what your setup, environment or everything you've tried.

1 solution

I would load the excel file into a DataTable object, and then add the records from the DataTable object into the database.

This CP article includes a class that imports Excel into a DataTable (and does a pretty good job of determining the correct column data types on the fly).

SQLXAgent - Jobs for SQL Express - Part 3 of 6[^]

Be sure to *read the article* before using the code. It will help immensely.
 
Share this answer
 
v3

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900