I have created a DataTable like this
Now while adding records into this table thing thing....Code:DataTable dtTable; ..................................... ..................................... dtTable = new DataTable(); ..................................... ..................................... DataColumn dcColumn = new DataColumn("PRIMARY_KEY"); dcColumn.AllowDBNull = false; dcColumn.AutoIncrement = true; dcColumn.AutoIncrementSeed = 0; dcColumn.AutoIncrementStep = 1; dcColumn.DataType = typeof(Int32); dcColumn.Unique = true; dtTable.Columns.Add(dcColumn); dtTable.Columns.Add("Product Name", Type.GetType("System.String")); dtTable.Columns.Add("Description", Type.GetType("System.String")); dtTable.Columns.Add("Unit Type", Type.GetType("System.String")); dtTable.Columns.Add("Supplier", Type.GetType("System.String")); dtTable.Columns.Add("Product Type", Type.GetType("System.String")); dtTable.Columns.Add("Supply Stock", Type.GetType("System.String")); dtTable.Columns.Add("Unit Package", Type.GetType("System.String"));
Does'nt work because of primary keyCode:dtTable.Rows.Add(txtProduct.Text, txtDesc.Text, cmbUnitType.SelectedItem.ToString(), cmbSupplier.SelectedItem.ToString(), cmbProductType.SelectedItem.ToString(), txtSupplyStock.Text, txtUnitPackage.Text);
So how can I specify only selected in which I want to add records?


Reply With Quote