Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: C#4.0
Hi..
I uploaded data from excel to store in db. if der is no repeated values means its getting uploaded. but if i hav same data in both DB and in Excel its rejecting whole excel sheet bcoz of my primary key in database. i want to upload all datas other tan primary key field.
 
Example:
Datas in Database(here i set primary key for numb)
 
numb name sex
 
1 shalu fem
2 sugan fem
3 prabha male
 
datas in Excel
 
100 suba fem
101 arun male
2 sugan fem( this row should not upload)
Posted 30-Jan-13 19:08pm
Edited 30-Jan-13 20:26pm
v2
Comments
JemiM at 31-Jan-13 0:15am
   
Please improve your question by adding what you have tried
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

Better you try to check the condition before insert the data into DB if the PK value is already exists in DB then no need to insert otherwise it's inserted..
 
(or)
 
In DB itself you set the PK column as Auto increment column.
  Permalink  
v2
Comments
shaluanbu at 31-Jan-13 1:40am
   
User cant able to see DB rit.. den how dey know whether its primary key or not.. i need to upload all dats other tan primary key values. but its rejecting whole excel sheet.
naveensenagasetti at 31-Jan-13 1:45am
   
I told you in coding wise you do that stuff, your not an end user ... right..?, you know that logic , what are the PK column etc.. so, you do that stuff in your coding wise i'm also do the excel uploading concept, my table PK col is auto increment column . So, i never face this type of issue. But in some other page i'm facing this issue at that time i'm checking whatever i mentioned in my solution
shaluanbu at 31-Jan-13 1:56am
   
Yah sure i ll do tat.. tanq..
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 2

Hi
kindly describe your data structure, which field is your primary key.
  Permalink  
Comments
naveensenagasetti at 31-Jan-13 1:49am
   
In question it self they mentioned that, PK col is "numb".

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



Advertise | Privacy | Mobile
Web03 | 2.8.150326.1 | Last Updated 31 Jan 2013
Copyright © CodeProject, 1999-2015
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100