Click here to Skip to main content
15,898,134 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
Hello!
I am getting an error while I am trying to insert data to the table columns in my code.
I have a table with columns like that;
ASIN varchar(25)
ReviewAverage float
TotalReviewCount int

On the code I have two generic lists:
C#
List<double> aveRating = new List<double>();
        List<int> totalReview = new List<int>();


And the insert into part is as follows;

Deneme tryout = new Deneme
                {
                    ASIN = itemASIN,
                    ReviewAverage = aveRating[Convert.ToInt32(itemASIN)],
                    TotalReviewCount = totalReview[Convert.ToInt32(itemASIN)]
                };
                db.Denemes.InsertOnSubmit(tryout);
                db.SubmitChanges();



When I debug both sides variables are the same. So the conversions seems to be successfully processed. But I cant figure out why it throws that error?
Posted
Updated 7-Dec-10 16:24pm
v3
Comments
Manfred Rudolf Bihy 7-Dec-10 22:17pm    
Edit: Code tags rectified.
Manfred Rudolf Bihy 7-Dec-10 22:22pm    
You could make us (and probably yourself) quite happy and more supportive of your question if you'd only tell us what that error was. You must have missed that by mistake. I hope. I mean telling us about an error that happend and keeping us all on edge and then not coming forth with some details, .... Yes I'm sure (self affirmative now) it must have happend by chance! :)
Orcun Iyigun 8-Dec-10 15:59pm    
Well to be honest I tried to post the question for almost 4 times but when I click ask the question everytime I try I had an error. because of that I needed to write it over and over again, so each time I write it I got exhousted and because of it I missed some parts sorry for not being clear enough.

1 solution

Where are you declaring itemASIN?

Separate your object initialization out to multiple lines so you can see which property assignment is throwing the exception. Off hand it sounds like itemASIN is not filled with the right type of data, so the Convert.ToInt32(string) call fails.

You could also look at using Int32.Parse(itemASIN)

If you clarify or post some more info I'm sure you'll receive more help.
 
Share this answer
 
Comments
Orcun Iyigun 8-Dec-10 15:56pm    
As you said there is something wrong on the itemASIN side. On the array there are multiple itemASIN s with the same value thats why it was throwing the error message. Thanks for the answer.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900