I have a simple method, which looks from my point of view entirely correct, but I
get the error:
;expected (in the line of declaration, CreateDataTable is red underlined )
The code is the following:
private void DataTable CreateDataTable(string selection){
int maxrowindex;switch (selection)
{
case "newtable" :DataColumn myDataColumn;
DataRow myDataRow;
myDataColumn = new DataColumn();
myDataColumn.DataType = System.Type.GetType("System.Int32");
myDataColumn.ColumnName = "id";
myDataColumn.ReadOnly = false;
myDataColumn.Unique = true;
myDataTable.Columns.Add(myDataColumn);myDataColumn = new DataColumn();
myDataColumn.DataType = System.Type.GetType("System.String");
myDataColumn.ColumnName = "Material";
myDataColumn.AutoIncrement = false;
myDataColumn.Caption = "Material";
myDataColumn.ReadOnly = false;
myDataColumn.Unique = false;
myDataTable.Columns.Add(myDataColumn);myDataColumn = new DataColumn();
myDataColumn.DataType = System.Type.GetType("System.Int32");
myDataColumn.ColumnName = "Amount";
myDataColumn.AutoIncrement = false;
myDataColumn.Caption = "Amount";
myDataColumn.ReadOnly = false;
myDataColumn.Unique = false;
myDataTable.Columns.Add(myDataColumn);DataColumn[] PrimaryKeyColumns = new DataColumn[1];
PrimaryKeyColumns[0] = myDataTable.Columns["id"];
myDataTable.PrimaryKey = PrimaryKeyColumns;//myDataSet = new DataSet();
//myDataSet.Tables.Add(myDataTable);myDataRow = myDataTable.NewRow();
myDataRow["id"] = 1;
myDataRow["Material"] = "Bezeichnung ";
myDataRow["Amount"] = 0;
myDataTable.Rows.Add(myDataRow);
maxrowindex = 1;break;
case "newrow" :
break;
case "deleterow" :
break;
}}
Does anybody know what is wrong?void or DataTable, pick one.
thanks!
0 comments:
Post a Comment