title: an error in ASP .NET4 + Linq
body: <p>I'm working on a project that using ASP .NET 4 C# (with Linq) and SQL server. All run well open page on my own computer IIS and connect to local sql database. and it is ok if connection to server database with IIS from my computer. Error happen if open published page (of cause it run from server IIS and will connect to server database). 
  Error from server's event log is</p>
  
  <blockquote>
    <p>Log Name:      Application
    Source:        ASP.NET 4.0.30319.0
    Date:          4/17/2015 1:33:11 PM
    Event ID:      1309
    Task Category: Web Event
    Level:         Warning
    Keywords:      Classic
    User:          N/A
    Computer:      SZHDB1.ds.jdsu.net
    Description:
    Event code: 3005 
    Event message: An unhandled exception has occurred. 
    Event time: 4/17/2015 1:33:11 PM 
    Event time (UTC): 4/17/2015 5:33:11 AM 
    Event ID: 89f5a478bff241d3aaa4798ce86ad707 
    Event sequence: 22 
    Event occurrence: 1 
    Event detail code: 0 </p>
    
    <p>Application information: 
        Application domain: /LM/W3SVC/1/ROOT/IMS-2-130737223782305527 
        Trust level: Full 
        Application Virtual Path: /IMS 
        Application Path: D:\WebSite\IMS\ 
        Machine name: SZHDB1 </p>
    
    <p>Process information: 
        Process ID: 3944 
        Process name: w3wp.exe 
        Account name: IIS APPPOOL\ASP.NET v4.0 </p>
    
    <p>Exception information: 
        Exception type: UpdateException 
        Exception message: An error occurred while updating the entries. See the inner exception for details.
       at System.Data.Mapping.Update.Internal.UpdateTranslator.Update(IEntityStateManager stateManager, IEntityAdapter adapter)
       at System.Data.Objects.ObjectContext.SaveChanges(SaveOptions options)
       at Log.set_storeLog(String value) in C:\Users\che57576\Documents\Visual Studio 2010\Projects\InstrManage\InstrManage\App\Common.cs:line 26
       at InstrManage.Admin.Group.GridView_group_SelectedIndexChanged(Object sender, EventArgs e) in C:\Users\che57576\Documents\Visual Studio 2010\Projects\InstrManage\InstrManage\Admin\Group.aspx.cs:line 164
       at System.Web.UI.WebControls.GridView.HandleEvent(EventArgs e, Boolean causesValidation, String validationGroup)
       at System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)</p>
    
    <p>String or binary data would be truncated.
    The statement has been terminated.
       at System.Data.SqlClient.SqlConnection.OnError(SqlException exception, Boolean breakConnection)
       at System.Data.SqlClient.TdsParser.ThrowExceptionAndWarning()
       at System.Data.SqlClient.TdsParser.Run(RunBehavior runBehavior, SqlCommand cmdHandler, SqlDataReader dataStream, BulkCopySimpleResultSet bulkCopyHandler, TdsParserStateObject stateObj)
       at System.Data.SqlClient.SqlDataReader.ConsumeMetaData()
       at System.Data.SqlClient.SqlDataReader.get_MetaData()
       at System.Data.SqlClient.SqlCommand.FinishExecuteReader(SqlDataReader ds, RunBehavior runBehavior, String resetOptionsString)
       at System.Data.SqlClient.SqlCommand.RunExecuteReaderTds(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, Boolean async)
       at System.Data.SqlClient.SqlCommand.RunExecuteReader(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, String method, DbAsyncResult result)
       at System.Data.SqlClient.SqlCommand.RunExecuteReader(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, String method)
       at System.Data.SqlClient.SqlCommand.ExecuteReader(CommandBehavior behavior, String method)
       at System.Data.SqlClient.SqlCommand.ExecuteDbDataReader(CommandBehavior behavior)
       at System.Data.Mapping.Update.Internal.DynamicUpdateCommand.Execute(UpdateTranslator translator, EntityConnection connection, Dictionary<code>2 identifierValues, List</code>1 generatedValues)
       at System.Data.Mapping.Update.Internal.UpdateTranslator.Update(IEntityStateManager stateManager, IEntityAdapter adapter)</p>
  </blockquote>
  
  <p>and the related code are here:
  'Common.cs':</p>
  
  <pre><code>public class Log
  {
  string conn, username;
  public string storeLog
  {
      set
      {
          using (AdminEntities myEntrities = new AdminEntities(conn))
          {
              IMSlog log = new IMSlog();
              log.user_name = username;
              log.date_time = DateTimeOffset.Now;
              log.what = value;
              myEntrities.IMSlogs.AddObject(log);
              myEntrities.SaveChanges();    //this is line 26
          }
      }
  }
  public Log(string linqConn,string userName)
  {
      conn = linqConn;
      username = userName;
  }
  }
  </code></pre>
  
  <p>'Group.aspx.cs':</p>
  
  <pre><code>protected void Page_Load(object sender, EventArgs e)
      {
  
  
              log = new Log(sqlconnstr, Session["UserName"].ToString());
  
      }
  </code></pre>
  
  <p>and in the same page, in the event:</p>
  
  <pre><code>protected void GridView_group_SelectedIndexChanged(object sender, EventArgs e)
      {
          bool result;
          result = Int32.TryParse(GridView_group.SelectedRow.Cells[0].Text.ToString(), out index);
          currentStatus = (GridView_group.SelectedRow.FindControl("CheckBox1") as CheckBox).Checked;
              using (TransactionScope scope = new TransactionScope())
              {
                  using (AdminEntities myEntrities = new AdminEntities(sqlconnstr))
                  {
                      admin_group c = (from r in myEntrities.admin_group
                                       where r.group_id == index
                                       select r).First();
                      c.group_enable = !currentStatus;
                      myEntrities.SaveChanges();
  
                      log.storeLog = "Set group ID " + index.ToString() + " to    " + Convert.ToString(!currentStatus);    // this is line 164
  
                  }
                  scope.Complete(); //  To commit.
  
              }
  
              queryGroup();
      }
  </code></pre>
  
  <p>when the above event be trigger, the error will happen.</p>
  
  <p>I've search from lots of time, not sure why my laptop is ok but server cannot.
  my laptop is win7 and sql express.
  server is asp .net 4 and SQL server 2008.</p>