I need to upload data from excel sheet to my grid view. but I need to prevent insertion of duplicate rows. so how can I do this with my dataset ? how do I check the dataset if it contains duplicates. if it has duplicates, I need to give an error message. here is my code.
odfExcelGet.Title = "Excel Upload";
odfExcelGet.FileName = "Excel";
odfExcelGet.Filter = "Excel File (*.xls;*.xlsx;)|*.xls;*.xlsx;";
odfExcelGet.InitialDirectory = @"c:\";
odfExcelGet.ShowDialog();
txtAddress.Text = odfExcelGet.FileName;
this.Cursor = Cursors.WaitCursor;
string ConnectionString = @"Provider=Microsoft.Jet.OLEDB.4.0;Data Source=";
ConnectionString += odfExcelGet.FileName;
ConnectionString += @";Extended Properties=""Excel 8.0;HDR=Yes;IMEX=1"";";
OleDbDataAdapter da = new OleDbDataAdapter("select * from [Sheet1$]", ConnectionString);
da.Fill(dsMain);
dgGrid.DataSource = dsMain.Tables[0];
how do I modify this code to prevent duplication.