J
Joe Keller
Hello,
I'd like to add a "NULL" value to a DataTable row that is expecting an
Int32. The following code works fine when I want to add a value of "32" to
the field..
1) DataSet myDataSet = new DataSet("dsTest");
2) DataTable myDataTable = myDataSet.Tables.Add("tblTest");
3) DataColumn myDataColumn = myDataTable.Columns.Add("colOne");
4) myDataColumn.DataType = System.Type.GetType("System.Int32");
5) myDataColumn.AllowDBNull = true;
6) string[] sTemp = new string[1];
7) sTemp[0] = "32";
8) myDataTable.Rows.Add(sTemp);
However, if I change line 7 to read sTemp[0] = "" (to reflect that the value
is NULL) I get a format exception. How do I add a NULL value to a field in
a DataRow?
Thanks,
Joe
I'd like to add a "NULL" value to a DataTable row that is expecting an
Int32. The following code works fine when I want to add a value of "32" to
the field..
1) DataSet myDataSet = new DataSet("dsTest");
2) DataTable myDataTable = myDataSet.Tables.Add("tblTest");
3) DataColumn myDataColumn = myDataTable.Columns.Add("colOne");
4) myDataColumn.DataType = System.Type.GetType("System.Int32");
5) myDataColumn.AllowDBNull = true;
6) string[] sTemp = new string[1];
7) sTemp[0] = "32";
8) myDataTable.Rows.Add(sTemp);
However, if I change line 7 to read sTemp[0] = "" (to reflect that the value
is NULL) I get a format exception. How do I add a NULL value to a field in
a DataRow?
Thanks,
Joe