我怎么能解决这个错误

我怎么能解决这个错误

本文介绍了我怎么能解决这个错误?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

错误:EntityFramework.dll中发生了'System.Data.Entity.Infrastructure.DbUpdateException'类型的异常,但未在用户代码中处理。





使用TimeSpan保存在数据库中时发生此错误... !!!



error: An exception of type 'System.Data.Entity.Infrastructure.DbUpdateException' occurred in EntityFramework.dll but was not handled in user code.


this error occurred when using TimeSpan for saving in database...!!!

var db = new Online_GameEntities();
            TimeSpan ts = new TimeSpan(0, 0, 0);
            DateTime dtnow = DateTime.Now;
            int h = dtnow.Hour;
            int m = dtnow.Minute;
            int s = dtnow.Second;
            int day = dtnow.Day;
            TimeSpan tsnow = new TimeSpan(day, h, m, s);
            TimeSpan tscreate = new TimeSpan(0, 12, 25);
            TimeSpan tscreated = tsnow.Add(tscreate);

            tbl_building insertbuild = new tbl_building();
            insertbuild.createdtime = (TimeSpan)tscreated;
            insertbuild.createtime = (TimeSpan)tscreate;
            insertbuild.levels = 1;
            insertbuild.c_id = "ttyuyt";
            insertbuild.firststate = true;
            insertbuild.name = "";
            insertbuild.x =5;
            insertbuild.y = 5;
            insertbuild.image = "b1.jpg" + "_" + 5;

            db.tbl_building.Add(insertbuild);
            db.SaveChanges();

推荐答案


这篇关于我怎么能解决这个错误?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-05 11:14