G
Guest
I'm having problems adding some data to my data table where one of my rows
contains a column that has a null value. Here is a snippet of my code
while ((strDataFileLine = DataFile.ReadLine()) != null) //Read till EOF
{
strTokens = strDataFileLine.Split(';'); //Parse
string by ;'s and put in strTokens
for(int i = 0; i < strTokens.Length; i++)
{
if (strTokens == "NULL")
strTokens = DBNull.Value.ToString();
}
if (intTotalColumns == strTokens.Length)
tblToLoad.Rows.Add(strTokens);
I'm reading the data from a text file, parsing it out into an array then
going through the array to check and see if the values contain "NULL" (it was
"" but i changed it to NULL for readability for my sake) When trying to add
the row I get the error
Unhandled Exception: System.ArgumentException: Input string was not in a
correct format.Couldn't store <DBNULL> in highquotaamount Column. Expected
type is Decimal. ---> System.FormatException: Input string was not in a
correct format.
I can't just check for NULL then put DBNull.value in my array because the
array wont accept that type being it's not a string. Is there a good way to
do this that I'm simply over looking?
contains a column that has a null value. Here is a snippet of my code
while ((strDataFileLine = DataFile.ReadLine()) != null) //Read till EOF
{
strTokens = strDataFileLine.Split(';'); //Parse
string by ;'s and put in strTokens
for(int i = 0; i < strTokens.Length; i++)
{
if (strTokens == "NULL")
strTokens = DBNull.Value.ToString();
}
if (intTotalColumns == strTokens.Length)
tblToLoad.Rows.Add(strTokens);
I'm reading the data from a text file, parsing it out into an array then
going through the array to check and see if the values contain "NULL" (it was
"" but i changed it to NULL for readability for my sake) When trying to add
the row I get the error
Unhandled Exception: System.ArgumentException: Input string was not in a
correct format.Couldn't store <DBNULL> in highquotaamount Column. Expected
type is Decimal. ---> System.FormatException: Input string was not in a
correct format.
I can't just check for NULL then put DBNull.value in my array because the
array wont accept that type being it's not a string. Is there a good way to
do this that I'm simply over looking?