2010-09-04 55 views
0

J'utilise ce code pour créer un fichier .dbf et il fonctionne très bien (je l'utilise OdbcConnection)Comment utiliser l'identité sur une colonne dans .dbf?

string TblInventory = "Create Table Inventory (Id int , Date datetime, CreatedBy char(100))"; 
    OdbcCommand cmd = new OdbcCommand(TblInventory, odbconn); 
    cmd.ExecuteNonQuery(); 

Insérer fonctionne bien:

"Insert Into Inventory (Id, Date , CreatedBy) Values(2,'2010/05/05','Gigi')"; 

Comment puis-je faire la colonne Id autoincrement? .

+0

Basculez vers SQL Server Express. Ce n'est pas .DBF dBASE, et n'est-ce pas mort il y a environ 10 ans? –

+0

Vous avez raison mais ce n'est pas à moi de décider. – jane

Répondre

0

Essayez d'utiliser CREATE TABLE INVENTAIRE (ID autoinc, ....

0

Utilisation AUTOINC de CREATE TABLE pour permettre auto-incrémentée

[AUTOINC [NEXTVALUE NextValue [STEP StepValue]]] [DEFAULT eExpression1] 

Jetez un oeil sur les liens suivants pour plus d'informations:

http://msdn.microsoft.com/en-us/library/aa976850%28VS.71%29.aspx

http://msdn.microsoft.com/en-us/library/aa977477%28v=VS.71%29.aspx

string TblInventory = "Create Table Inventory (Id i autoinc nextvalue 1 step 1, Date datetime, CreatedBy char(100))"; 
OdbcCommand cmd = new OdbcCommand(TblInventory, odbconn); 
cmd.ExecuteNonQuery();