简体   繁体   English

SQL Compact,新数据集,标识列的顺序相反并且没有提交?

[英]SQL Compact, new DataSet, identity column in reverse order and no commit?

I created a new .dsf database for my application. 我为我的应用程序创建了一个新的.dsf数据库。 I added just one table with two columns, "ID" (int, auto-increment, step=1, start=1) and another column called "Name" of nchar. 我只添加了一个包含两列的表:“ ID”(整数,自动递增,step = 1,start = 1)和另一列称为nchar的“名称”。

Then I added a new datagrid, choosing the dataset (strongly typed one) created with the table from dsf database. 然后,我添加了一个新的datagrid,从dsf数据库中选择了用该表创建的数据集(强类型输入)。 The grid allows me to add news rows, but the column "ID" shows that the row just added as an id of "-1" and so on adding more rows. 网格允许我添加新闻行,但“ ID”列显示该行刚刚以ID“ -1”的形式添加,依此类推添加了更多行。

In addition, no changes are made on .dsf. 此外,.dsf上没有任何更改。 Sad, what I'm doing wrong? 难过,我做错了什么? This is driving me crazy... 这真让我抓狂...

EDIT SEE PICTURE BELOW : simple example.. I added a few lines in the table (using visual studio editor). 编辑下面的图片 :简单的示例。我在表中添加了几行(使用Visual Studio编辑器)。

    public Form1()
    {
        InitializeComponent();
        TabellaTableAdapter ta = new TabellaTableAdapter();
        ta.Fill(dataSet1.Tabella); // Fill the dataset with "Tabella" content
    }

    private void button1_Click(object sender, EventArgs e)
    {
        Data.DataSet1.TabellaRow newrow = dataSet1.Tabella.NewTabellaRow();
        newrow.Name = textBox1.Text; // Set the "Name" field
        dataSet1.Tabella.AddTabellaRow(newrow); // Add the new row
        dataSet1.Tabella.AcceptChanges(); // Commit
    }

Pressing the button creates those new rows (with negative ids ) and no changes are commited back to the database: 按下按钮将创建这些新行(带有负ID ),并且不会将任何更改提交回数据库: 替代文字

接受更改后,这些ID值会更改吗?

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

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM