jgoodale

jgoodale

  • NA
  • 87
  • 0

Primary key autoincrement not working

Sep 29 2024 6:54 PM

trying to do a primary key that is autoincrement. Here is the part for Thw ID in code.

Thanks for looking at this and helpping.

John

 

string connectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + FileBinPath; (OleDbConnection connection = new OleDbConnection(connectionString)) Catalog catalog = new Catalog(); catalog.Create(connectionString); Table table = new Table(); table.Name = "Users"; DataColumn columnId = new DataColumn(); columnId.DataType = System.Type.GetType("System.Int32"); columnId.AutoIncrement = true; columnId.AutoIncrementSeed = 1; columnId.AutoIncrementStep = 1; columnId.AllowDBNull = false; Column nameCol = new Column(); nameCol.Name = "Name"; nameCol.Type = ADOX.DataTypeEnum.adVarWChar; nameCol.DefinedSize = 60; table.Columns.Append(columnId); table.Columns.Append(nameCol); catalog.Tables.Append(table); DataGridView1.DataSource = table;

Answers (1)