title: Why this strange behavior of sqlbulkcopy in a asp.net website running under iis?
body: <p>I'm using <code>SqlClient.SqlBulkCopy</code> to try and bulk copy a csv file into a
  database.  I am getting the following error after calling the
  ..WriteToServer method.</p>
  
  <blockquote>
    <p>"The given value of type String from
    the data source cannot be converted to
    type decimal of the specified target
    column."</p>
  </blockquote>
  
  <p>Here is my code,</p>
  
  <pre><code> dt.Columns.Add("IsDeleted", typeof(byte));
      dt.Columns.Add(new DataColumn("CreatedDate", typeof(DateTime)));
      foreach (DataRow dr in dt.Rows)
      {
          if (dr["MobileNo2"] == "" &amp;&amp; dr["DriverName2"] == "")
          {
              dr["MobileNo2"] = null;
              dr["DriverName2"] = "";
          }
          dr["IsDeleted"] = Convert.ToByte(0);
          dr["CreatedDate"] = Convert.ToDateTime(System.DateTime.Now.ToString());
      }
      string connectionString = System.Configuration.ConfigurationManager.
                            ConnectionStrings["connectionString"].ConnectionString;
      SqlBulkCopy sbc = new SqlBulkCopy(connectionString);
      sbc.DestinationTableName = "DailySchedule";
      sbc.ColumnMappings.Add("WirelessId", "WirelessId");
      sbc.ColumnMappings.Add("RegNo", "RegNo");
      sbc.ColumnMappings.Add("DriverName1", "DriverName1");
      sbc.ColumnMappings.Add("MobileNo1", "MobileNo1");
      sbc.ColumnMappings.Add("DriverName2", "DriverName2");
      sbc.ColumnMappings.Add("MobileNo2", "MobileNo2");
      sbc.ColumnMappings.Add("IsDeleted", "IsDeleted");
      sbc.ColumnMappings.Add("CreatedDate", "CreatedDate");
      sbc.WriteToServer(dt);
      sbc.Close();
  </code></pre>
  
  <p>There is no error when running under visual studio developement server but it gives me an error when running under iis.....</p>
  
  <p>Here is my sql server table details,</p>
  
  <pre><code>[Id] [int] IDENTITY(1,1) NOT NULL,
  [WirelessId] [int] NULL,
  [RegNo] [nvarchar](50) NULL,
  [DriverName1] [nvarchar](50) NULL,
  [MobileNo1] [numeric](18, 0) NULL,
  [DriverName2] [nvarchar](50) NULL,
  [MobileNo2] [numeric](18, 0) NULL,
  [IsDeleted] [tinyint] NULL,
  [CreatedDate] [datetime] NULL,
  </code></pre>