Click here to Skip to main content
15,921,694 members
Home / Discussions / ASP.NET
   

ASP.NET

 
GeneralRe: How do I remove the commas after reading a CSV file into a streamreader Pin
Guffa16-Dec-08 14:29
Guffa16-Dec-08 14:29 
GeneralRe: How do I remove the commas after reading a CSV file into a streamreader Pin
Tina P16-Dec-08 14:56
Tina P16-Dec-08 14:56 
GeneralRe: How do I remove the commas after reading a CSV file into a streamreader Pin
Guffa16-Dec-08 15:09
Guffa16-Dec-08 15:09 
GeneralRe: How do I remove the commas after reading a CSV file into a streamreader Pin
Tina P16-Dec-08 16:08
Tina P16-Dec-08 16:08 
GeneralRe: How do I remove the commas after reading a CSV file into a streamreader Pin
Guffa17-Dec-08 5:09
Guffa17-Dec-08 5:09 
GeneralRe: How do I remove the commas after reading a CSV file into a streamreader Pin
Tina P17-Dec-08 7:30
Tina P17-Dec-08 7:30 
GeneralRe: How do I remove the commas after reading a CSV file into a streamreader Pin
Guffa17-Dec-08 11:52
Guffa17-Dec-08 11:52 
GeneralRe: How do I remove the commas after reading a CSV file into a streamreader Pin
Tina P17-Dec-08 14:10
Tina P17-Dec-08 14:10 
Thanks again Guffa, yeah i renamed them to simple one word with no spaces.

Now I'm running into a bigger issue though...i feel pretty embarassed but it is what it is, I just don't have enough experience in development.

So right now for development purposes I have modified that file i'm reading the data from so that it has same number of columns with the headers in the third line.

Evantually the file will look something like this:

Blah Blah, More blah, etc

Blah Blah, More blah, etc

Blah Blah, More blah, etc

These lines above needs to be ignored. I had to change the looping structure a little bit because it was throwing an array index out of bound exception.
Here is what i have now:

for (int i = 0; i < 11; i ++)
                        {
                            while ((line = sr.ReadLine()) != null)
                            {
                                string[] col = line.Split(',');

                                cmd.Parameters["@Name"].Value = col[i];
                                cmd.Parameters["@location"].Value = col[i + 1];
                                cmd.Parameters["@pincode"].Value = DateTime.Now.Date;
                                cmd.Parameters["@Date"].Value = col[i + 3];
.
.
.
.
                                cmd.Parameters["@eta"].Value = col[i + 10];


                                cmd.ExecuteNonQuery();
                            }
                        }


As you notice in the for loop, i had to hard code the range because col array hasn't been created at this time...this may not be a good idea moving forward!

Secondly, I'm doing single increments (i=i+1) as you can see because the data is going to be in it separate column right next to each other.

Lastly, i notice the code above seems to be ignoring the very first line in the line...what do you think is deriving that in the for loop?

What is your take on this, this seems to be inserting the values in the data base ok? But I don;t think the for and while loops logic is correct? Can you please elaborate on this?

Thank you so much.
Tina
GeneralRe: How do I remove the commas after reading a CSV file into a streamreader Pin
Tina P17-Dec-08 19:37
Tina P17-Dec-08 19:37 
GeneralRe: How do I remove the commas after reading a CSV file into a streamreader Pin
Guffa26-Dec-08 7:51
Guffa26-Dec-08 7:51 
QuestionHELP! using Replace function to replace letters with images Pin
icecandy15-Dec-08 12:36
icecandy15-Dec-08 12:36 
AnswerRe: HELP! using Replace function to replace letters with images Pin
Christian Graus15-Dec-08 13:19
protectorChristian Graus15-Dec-08 13:19 
AnswerRe: HELP! using Replace function to replace letters with images Pin
treputt15-Dec-08 14:17
treputt15-Dec-08 14:17 
QuestionAssigning and retrieving values from checkboxes which are dynamically created. Pin
Member 340288615-Dec-08 10:12
Member 340288615-Dec-08 10:12 
AnswerRe: Assigning and retrieving values from checkboxes which are dynamically created. Pin
Christian Graus15-Dec-08 10:24
protectorChristian Graus15-Dec-08 10:24 
GeneralRe: Assigning and retrieving values from checkboxes which are dynamically created. Pin
Member 340288615-Dec-08 11:16
Member 340288615-Dec-08 11:16 
GeneralRe: Assigning and retrieving values from checkboxes which are dynamically created. Pin
Christian Graus15-Dec-08 11:41
protectorChristian Graus15-Dec-08 11:41 
AnswerRe: Assigning and retrieving values from checkboxes which are dynamically created. Pin
Nishant Singh15-Dec-08 17:22
Nishant Singh15-Dec-08 17:22 
QuestionGridView databinding event handler Pin
compninja2515-Dec-08 8:37
compninja2515-Dec-08 8:37 
AnswerRe: GridView databinding event handler Pin
Christian Graus15-Dec-08 15:19
protectorChristian Graus15-Dec-08 15:19 
GeneralRe: GridView databinding event handler Pin
compninja2516-Dec-08 3:05
compninja2516-Dec-08 3:05 
QuestionSeting focus for controls after postback Pin
chandra vempati15-Dec-08 8:27
chandra vempati15-Dec-08 8:27 
AnswerRe: Seting focus for controls after postback Pin
Christian Graus15-Dec-08 9:55
protectorChristian Graus15-Dec-08 9:55 
Question[Message Deleted] Pin
harcaype15-Dec-08 7:39
harcaype15-Dec-08 7:39 
AnswerRe: cannot run .htm in localhost Pin
Christian Graus15-Dec-08 9:55
protectorChristian Graus15-Dec-08 9:55 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.