开发者

ADO.NET autoincrement primary keys

I'm trying to use SQLite with ADO.NET TableAdapters and xsd schema.

What is the best practice of generating autoincrement values? SQLite manual says that key is generated automatically if NULL is sent for PRIMARY KEY field. But schema editor doesn't allow NULL.

With DataReader it's probably easier, but I would like to use functionality of TableAdapters.

-- UPDATE --

This was somewhere helpful: msdn

But now another question: How to get the generated key from DB when INSERT is used? I see that when the INSERT co开发者_如何学编程mmand executed, my table (in memory) still contains 0, instead of key generated by DB.

Ofcourse I can use fill() method to get the updated value, but it looks very unoptimal.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜