开发者

LINQtoSQL Data not Inserting into SQL Combact Edition [duplicate]

This question already has answers here: Closed 11 years ago.

Possible Duplicate:

Why are my LINQ INSERTS not persisting in SQL Server CE 3.5?

I have a local database "Database1.sdf" and i'm trying to insert data into the table "User" using LinqToSql.

    public void DBTest()
    {
        string con = "Data Source=|DataDirectory|\\Database1.sdf";
        Database1 db = new Database1(con);
        User user=new User();
        user.ID=3;
        user.Name="testdata";
        db.User.InsertOnSubmit(user);
        db.SubmitChanges();

        var q = from t in db.User
                select t;
        foreach (var t in q)
        {
            Console.Out.WriteLine(t.Name);
        }
    }

The select query after the insertion works fine and shows the result, but the database is not updated. If i go and 开发者_运维知识库check the table manually it is empty. If i run the program again it doesn't throw any exception of primary key violation.

LINQtoSQL Data not Inserting into SQL Combact Edition [duplicate]

Thanks


Why are my LINQ INSERTS not persisting in SQL Server CE 3.5?

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜