O
OnlineSpirit
Guest
Create Table
CREATE TABLE `products` (
`id` int(11) unsigned NOT NULL AUTO_INCREMENT,
`name` varchar(45) NOT NULL,
PRIMARY KEY (`id`),
UNIQUE KEY `UQ_Product_Name` (`name`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
Init. columns for DataTable
pColId = new DataColumn()
{
AllowDBNull = false,
AutoIncrement = true, // <-- AutoIncrement: true
ColumnName = "id",
DataType = typeof(uint),
Unique = true,
Caption = "Id",
AutoIncrementSeed = 0,
AutoIncrementStep = 1
};
pColName = new DataColumn()
{
ColumnName = "name",
DataType = typeof(string),
AllowDBNull = false,
Unique = true,
MaxLength = 45
};
Columns.Add(this.pColId);
Columns.Add(this.pColName);
Constraints.Clear();
/* After added constraints, property ` AutoIncrement` value update to FALSE */
Constraints.Add(new UniqueConstraint("PRIMARY", new DataColumn[] { this.pColId }, true));
Constraints.Add(new UniqueConstraint("UQ_Product_Name", pColName, false));
/* If change value to TRUE, property DataType update to Int32 */
pColId.AutoIncrement = true;
I can use AutoIncrement column data type as UInt32? Or is it not possible?
Continue reading...
CREATE TABLE `products` (
`id` int(11) unsigned NOT NULL AUTO_INCREMENT,
`name` varchar(45) NOT NULL,
PRIMARY KEY (`id`),
UNIQUE KEY `UQ_Product_Name` (`name`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
Init. columns for DataTable
pColId = new DataColumn()
{
AllowDBNull = false,
AutoIncrement = true, // <-- AutoIncrement: true
ColumnName = "id",
DataType = typeof(uint),
Unique = true,
Caption = "Id",
AutoIncrementSeed = 0,
AutoIncrementStep = 1
};
pColName = new DataColumn()
{
ColumnName = "name",
DataType = typeof(string),
AllowDBNull = false,
Unique = true,
MaxLength = 45
};
Columns.Add(this.pColId);
Columns.Add(this.pColName);
Constraints.Clear();
/* After added constraints, property ` AutoIncrement` value update to FALSE */
Constraints.Add(new UniqueConstraint("PRIMARY", new DataColumn[] { this.pColId }, true));
Constraints.Add(new UniqueConstraint("UQ_Product_Name", pColName, false));
/* If change value to TRUE, property DataType update to Int32 */
pColId.AutoIncrement = true;
I can use AutoIncrement column data type as UInt32? Or is it not possible?
Continue reading...