Re: Adding a NULL to an array then adding array to a data table
- From: "Jeff Dillon" <jeffdillon@xxxxxxxxxxx>
- Date: Wed, 17 May 2006 16:55:57 -0700
Put a 0 in instead?
"Fiddelm3742" <Fiddelm3742@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote in message
news:7AC4A4A0-7182-4D32-B2EF-C70E16BA6811@xxxxxxxxxxxxxxxx
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[i] == "NULL")
strTokens[i] = 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?
--
Matt
www.Fiddelke.org
.
- Prev by Date: Re: 'MySql.Data.MySqlClient.MySqlConnection' not defined
- Next by Date: Re: Sql Server Connection Irritations (again)
- Previous by thread: Sql Server Connection Irritations (again)
- Next by thread: Re: Adding a NULL to an array then adding array to a data table
- Index(es):
Relevant Pages
|