简体   繁体   English

使用SQL Compact 3.5插入实体框架

[英]Insert with Entity Framework with SQL Compact 3.5

I dont know why my sql request does not insert on database. 我不知道为什么我的sql请求没有插入数据库。

I think the db.Create(pers) does works. 我认为db.Create(pers)确实有效。

private void SaveInsertAnim(object sender, EventArgs e)
{
    using (var db = new DJURINGA_DIRECTOREntities())
    {
        PERSONNE pers = new PERSONNE();


        pers.NOM = textBox1.Text;
        pers.PRENOM = textBox2.Text;
        pers.ADRESSE = textBox9.Text;
        pers.CODEPORTE = textBox3.Text;
        pers.EMAIL = textBox4.Text;
        pers.TELEPHONE = textBox5.Text;
        pers.NUMSECU = textBox6.Text;
        pers.DATENAISSANCE = Convert.ToDateTime(dateTimePicker2.Text); 
        pers.LIEUNAISSANCE = textBox8.Text;
        pers.DATEDEBUTSEJOUR = Convert.ToDateTime(dateTimePicker1.Text);
        if(!string.IsNullOrWhiteSpace(comboBox2.Text)) pers.NOMBRESEMAINETRAVAILLE = int.Parse(comboBox2.Text);
        pers.REDUCTIONSNCF = textBox10.Text;
        if (!string.IsNullOrWhiteSpace(comboBox1.Text)) pers.NOMBREJOURPRECAMP = int.Parse(comboBox1.Text);


         db.Create(pers);
         db.SaveChanges();


        this.Hide();
    }
}

My Functions Create() : 我的函数Create():

public static T Create(this ObjectContext context, T objetToCreate, bool save = false) where T : EntityObject { try { var type = context.GetSetBase(typeof(T)); 公共静态T创建(此ObjectContext上下文,T objetToCreate,布尔保存=假),其中T:EntityObject {试试{var type = context.GetSetBase(typeof(T));

            if (context.GetKeyName<T>().Count == 1)
            {
                context.SetValeurToKey(objetToCreate);
            }

            context.AddObject(type.Name, objetToCreate);
            if (save) context.SaveChanges();
            return objetToCreate;
        }
        catch (Exception ex)
        { throw ex; }
    }

Do you have any ideas ? 你有什么想法 ?

i have no error, but nothing works .. 我没有错误,但没有任何效果..

Look for a copy of the database file in your bin/debug folder. 在bin / debug文件夹中查找数据库文件的副本。 Possible solutions: specify a full path to the database file in your connectionstring. 可能的解决方案:在连接字符串中指定数据库文件的完整路径。 Do not include the database file a content in your project 不要在项目中包含数据库文件的内容

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 没有配置文件的实体框架6 SQL Server Compact 3.5 - Entity Framework 6 SQL Server Compact 3.5 without Config file Entity Framework 4.3和SQL Server Compact Edition 3.5的更新缓慢 - Slow updates with Entity Framework 4.3 and SQL Server Compact Edition 3.5 实体框架3.5 + SQL Server Compact 3.5,由于强制转换性能较慢 - Entity Framework 3.5 + SQL Server Compact 3.5, slow performace because of cast 在带有实体框架 6.4 的 SQL 服务器紧凑型中无法使用 IDENTITY_INSERT - Not working IDENTITY_INSERT in SQL Server Compact with Entity Framework 6.4 将记录插入到SQL Server CE数据库移动到另一个线程? C#Compact Framework 3.5 - Move record insert to SQL Server CE database into another thread? C# Compact Framework 3.5 .Net Compact Edition 3.5是否支持实体框架? - Does the .Net Compact Edition 3.5 support the Entity Framework? 具有实体框架的SQL Server Compact Edition - SQL Server Compact Edition with Entity Framework 将Entity Framework 6与SQL Server Compact 4一起使用 - Using Entity Framework 6 with SQL Server Compact 4 Microsoft Compact Framework 3.5上的AoP - AoP on Microsoft Compact Framework 3.5 紧凑框架3.5上的XmlSerialization问题 - XmlSerialization problems on compact framework 3.5
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM