Click here to Skip to main content
15,905,508 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
private void btnUploadData_Click(object sender, EventArgs e)
        {

            try
            {
                bool check = validationUpload();
                if (check == false)
                {
                   // MessageBox.Show("invalid entry");
                    return;
                }
                else
                {

                    string connectionstring = "Data Source=10.10.5.251;Initial Catalog=Demo;User ID=dev;Password=SamDev@2020";
                    DapperPlusManager.Entity<UploadSBAPayment>().Table("UploadSBAPayment");
                    List<UploadSBAPayment> SBAPayment = uploadSBAPaymentBindingSource.DataSource as List<UploadSBAPayment>;
                    if (SBAPayment != null)
                    {
                        using (SqlConnection con = new SqlConnection(connectionstring))
                        {
                            con.Open();
                            con.BulkInsert(SBAPayment);

                            con.Close();
                        }

                    }
                }
                    MessageBox.Show("Data Upload Successfully");
                
                
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "Message", MessageBoxButtons.OK, MessageBoxIcon.Error);

            }          

        }


What I have tried:

i have try C# upload excel file load to gidview then after gridview sql table that time if duplicate data notice to user ...................................................
Posted
Updated 7-Aug-20 7:04am
Comments
BillWoodruff 7-Aug-20 10:06am    
To assist you, we need to know more about how you define "duplicate." And, describe what the validationUpload() function does.

1 solution

The error says you have duplicates in your data and the database is rejecting your bulk import. Either don't do it with bulk import or clean out the data first.
 
Share this answer
 

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