I am inserting into database excel sheet, I have been able to upload with and without sheet names, I just want to know how can I prevent the data from being inserting multiple times e.g. if my sheet has 2 records the loop inserts it twice and the table ends up looking like this:
ID  DOB       NAME  SURNAME 
1   1/02/1998 jack  turner
2   2/02/1989 jill  blue
1   1/02/1998 jack  turner
2   2/02/1989 jill  blue
Code:
public void up(string sFileName = @"filename") { 
    string ssqltable = "[dbo].[My_Table]";
    //string sFileName = @"filename";
    try{
        string sConStr = string.Format("Provider=Microsoft.ACE.OLEDB.12.0;Data Source={0};Extended Properties='Excel 8.0;HDR=YES';", sFileName);
        DataTable dt = new DataTable();
        SqlConnection sqlconn = new SqlConnection(strConnString);
        sqlconn.Open();
        using (OleDbConnection connection = new OleDbConnection(sConStr))
        {
            connection.Open();
            dt = connection.GetOleDbSchemaTable(OleDbSchemaGuid.Tables, new object[] { null, null, null, "TABLE" });
            var sheets = dt.Rows[0].Field<string>("TABLE_NAME");
            foreach(var sheet in sheets) //loop through the collection of sheets ;)
            {
                //your logic here...
                string myexceldataquery = string.Format("Select * FROM [{0}]; ", sheets);
                //get data
                OleDbConnection oledbconn = new OleDbConnection(sConStr);
                OleDbCommand oledbcmd = new OleDbCommand(myexceldataquery, oledbconn);
                oledbconn.Open();                 
                OleDbDataReader dr = oledbcmd.ExecuteReader();
                {
                    DataTable table = new DataTable("benlist");
                    table.Load(dr);
                    // add two extra columns to data table to be added to database table
                    table.Columns.Add("name",typeof(string));
                    table.Columns.Add("surname",typeof(string));
                    // add data to additional columns
                    foreach (DataRow row in table.Rows){
                        row["name"] =Session["Username"].ToString();
                        row["surname"] = Session["Username"].ToString();
                    }
                    SqlBulkCopy bulkcopy = new SqlBulkCopy(strConnString);
                    bulkcopy.DestinationTableName = ssqltable;
                    ////Mapping Table column    
                    bulkcopy.ColumnMappings.Add("IDNumber", "[IDNumber]");
                    bulkcopy.ColumnMappings.Add("DOB", "[DOB]");
                    bulkcopy.ColumnMappings.Add("name", "[name]");
                    bulkcopy.ColumnMappings.Add("surname", "[surname]");
                    //sqlcmd.ExecuteNonQuery();
                    //while (dr.Read())
                    //{
                        bulkcopy.WriteToServer(table);
                    //}
                    connection.Close();
                    sqlconn.Close();
                }
            }
        }   
    }
    catch (Exception){}
    ClientScript.RegisterStartupScript(GetType(), "alert", "alert('File Uploaded');", true);
}
I expect the data to be inserted once no duplicates e.g
ID  DOB       NAME  SURNAME 
1   1/02/1998 jack  turner
2   2/02/1989 jill  blue
 
    