public void createTablesTable(ref DataSet myDataSet, ref StructFunctions.tablesStruct myDataTableStruct) { //StructFunctions.tablesStruct myDataTableStruct = new StructFunctions.tablesStruct(); string TableName = myDataTableStruct.tableName; DataTable myTable = myDataSet.Tables.Add(TableName); DataColumnCollection TableCols; TableCols = myTable.Columns; //Primary key GUID DataColumn colGuid = TableCols.Add(myDataTableStruct.GUID_fieldName, typeof(Guid)); colGuid.AllowDBNull = false; colGuid.Unique = true; colGuid.DefaultValue = Guid.NewGuid(); myTable.PrimaryKey = new DataColumn[] { colGuid }; //Fields DataColumn colID = TableCols.Add(myDataTableStruct.ID_fieldName, typeof(int)); DataColumn colDescription = TableCols.Add(myDataTableStruct.Description_fieldName, typeof(string)); DataColumn colType = TableCols.Add(myDataTableStruct.Type_fieldName, typeof(int)); DataColumn colTypeDescription = TableCols.Add(myDataTableStruct.Type_Description_fieldName, typeof(string)); DataTableCollection myDataTableColl = myDataSet.Tables; }
public Guid populateTableRow(ref DataTable myDataTable, StructFunctions.tablesStruct myDataTableStruct) { DataRow row = myDataTable.NewRow(); row[myDataTableStruct.GUID_fieldName] = Guid.NewGuid(); row[myDataTableStruct.Description_fieldName] = myDataTableStruct.Description; row[myDataTableStruct.ID_fieldName] = myDataTableStruct.ID; row[myDataTableStruct.Type_fieldName] = myDataTableStruct.Type; row[myDataTableStruct.Type_Description_fieldName] = myDataTableStruct.Type_Description; myDataTable.Rows.Add(row); return((Guid)row[myDataTableStruct.GUID_fieldName]); }