About green triangle indicator in Excel cells’ upper-left corner

When I generate excel data report, there are a few result columns with mixed number and text. I define the column as text and the cells include numbers in this column show green triangles at each cell.
If this green triangel bothers you, you can always turn it off from Tools>> Options>>Error checking tab:  Store number stored as text. and click OK. The green triangles will disppear for the column with mixed number and text values.
Advertisements

Import from Excel to SQL Server through BulkCopy with ColumnMappings

 

Here is a code snippet I copied from a question I answered at ASP.NET forum:

If the source columns are not matching with destination in position and/or name, you need to define ColumnMappings during the bulkcopy.

protected void Page_Load(object sender, EventArgs e)
   {
       // Connection String to Excel Workbook
       string excelConnectionString = @"Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\property.xls;Extended Properties=""Excel 8.0;HDR=YES;""";

       // Create Connection to Excel Workbook
       using (System.Data.OleDb.OleDbConnection connection = new System.Data.OleDb.OleDbConnection(excelConnectionString))
       {
           System.Data.OleDb.OleDbCommand command = new System.Data.OleDb.OleDbCommand
           ("Select CountyCode,PropertyAppraiserName FROM [county$]", connection);

           connection.Open();

           // Create DbDataReader to Data Worksheet
           using (System.Data.OleDb.OleDbDataReader dr = command.ExecuteReader())
           {
               // SQL Server Connection String
               string sqlConnectionString = "Data Source=.; Database=test_for_forum;Integrated Security=True";

               // Bulk Copy to SQL Server
               using (System.Data.SqlClient.SqlBulkCopy bulkCopy = new System.Data.SqlClient.SqlBulkCopy(sqlConnectionString))
               {
                   bulkCopy.DestinationTableName = "tblPropertyAppraiser";

 

                   //Define ColumnMappings: source –destination

                   bulkCopy.ColumnMappings.Add("CountyCode", "DesCountyCode");
                   bulkCopy.ColumnMappings.Add("DesPropertyAppraiserName", "PropertyAppraiserName");
                  

 

bulkCopy.WriteToServer(dr);
               }
           }
       }
   }

http://forums.asp.net/t/1405240.aspx