5 Replies - 485 Views - Last Post: 04 May 2013 - 01:08 AM Rate Topic: -----

#1 3c0der  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 2
  • Joined: 30-April 13

saving 25 variables in struct array or classes

Posted 30 April 2013 - 05:42 PM

Hi all,

I am building a simple CSV reader and I want to process the data and then on the end upload my data to mysql.

I can read the data from CSV no problem there however I do not know how to store the temp data correctly I would normally do this in an array of structs in C.

I guess C# works different I found libraries structs and classes but I can't find out what the best method is.

my data about 25 strings and int's.

I would like to be able to have 3 classes at least that can read, process and store this data.

do you guys have any suggestions.

Many thanks

Is This A Good Question/Topic? 0
  • +

Replies To: saving 25 variables in struct array or classes

#2 modi123_1  Icon User is offline

  • Suitor #2
  • member icon



Reputation: 9287
  • View blog
  • Posts: 34,811
  • Joined: 12-June 08

Re: saving 25 variables in struct array or classes

Posted 30 April 2013 - 06:09 PM

why not use a dataset object?
Was This Post Helpful? 0
  • +
  • -

#3 baavgai  Icon User is online

  • Dreaming Coder
  • member icon

Reputation: 5848
  • View blog
  • Posts: 12,707
  • Joined: 16-October 07

Re: saving 25 variables in struct array or classes

Posted 01 May 2013 - 04:30 AM

View Post3c0der, on 30 April 2013 - 08:42 PM, said:

I would normally do this in an array of structs in C.


Then do it the same in C#. Prefer class to struct. Use List instead of array. However, the logic of the code should be near identical.

What would be your C approach and what in C# is stopping you?
Was This Post Helpful? 0
  • +
  • -

#4 aczwicker  Icon User is offline

  • New D.I.C Head
  • member icon

Reputation: 2
  • View blog
  • Posts: 43
  • Joined: 23-May 12

Re: saving 25 variables in struct array or classes

Posted 02 May 2013 - 04:48 PM

Here is a nice article that I found that might help you with this issue.

It explains how to extract data from a CSV file and then save it into a SQL database using SqlBulkCopy after loading your CSV data into a DataSet.
This method should work fine for only 25 strings and ints.

http://www.codeproje...V-Import-Export
Was This Post Helpful? 0
  • +
  • -

#5 AdamSpeight2008  Icon User is offline

  • MrCupOfT
  • member icon


Reputation: 2264
  • View blog
  • Posts: 9,470
  • Joined: 29-May 08

Re: saving 25 variables in struct array or classes

Posted 03 May 2013 - 11:14 AM

Also you could use the Text Field Parser. Yes it vb.net but it available to use from C#
Was This Post Helpful? 0
  • +
  • -

#6 3c0der  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 2
  • Joined: 30-April 13

Re: saving 25 variables in struct array or classes

Posted 04 May 2013 - 01:08 AM

Hi all thank you for you answers!!

one thing I have to get used to is how can I have one data source lets say datatable and access this data from different classes is this possible like a global variable or some sort of accessor?
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1