Problem with placing data in SqlCe 2.0 database

  • Thread starter Thread starter tiger79
  • Start date Start date
T

tiger79

Hi,
i'm reading data from a txt file so that i can fill a Sql Ce 2.0 database
with it.
Now I have a problem because there is a int field of the database i want to
fill, but when i read in the file (which is a long string conataining the
data for every column and using the % character as delimiter) i get a format
error if the int data is empty :
for example this is the input string

hello%i%am%%sexy

ok my database exist out of 5 columns
column 1, 2, 3 are text (nvarchar)
column 4 is number (int)
column 5 is text again

so it will fill columns 1,2 and 3 but it will stop at column 4 because it
doesnt know any integer which stands for that empty character... I thought
it would take zero but idt doesnt :(

int Age;

insertCommand1.Parameters.Add(new SqlCeParameter("Age", SqlDbType.Int,16));

Age = Convert.ToInt32(Asplit[8]);

insertCommand1.Parameters["Age"].Value = Age;



this is what i'm using now but it wont work...



please help me out of this, been working on it for nearly a day and its
driving me crazy :(
 
Hi,
After your convert to Age try to check the value of Age, if it's
null/nothing set it to 0

Arne
 
Back
Top