tags:

views:

28

answers:

2

Hi I am using this code to create a .dbf file and it works fine ( i use OdbcConnection )

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

Insert works well:

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

How can i make the Id column autoincrement?

A: 

Try using CREATE TABLE INVENTORY (ID autoinc, ....

Vidar Nordnes
A: 

Use AUTOINC of CREATE TABLE to enable auto-incrementing.

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

Take a look at the following links for more information:

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();
Edward Leno