Click here to Skip to main content
15,882,163 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
i have used the following to to extract data from a text file & store values in an array-

C#
public class data
        {
            public string date, time, mag, depth;
            public double lat, lon;
        }
        private void view_file_Load(object sender, EventArgs e)
        {

            string str;
            List<data> gd = new List<data>();
            try
            {
                using (StreamReader sr = new StreamReader("C:\\Windows\\Temp\\op.txt"))
                {
                    string line;
                    while ((line = sr.ReadLine()) != null)
                    {
                        string[] arr = line.Split(new char[] { ' ' }, System.StringSplitOptions.RemoveEmptyEntries);
                        while (sr.Peek() > 0)
                        {

                            string[] s = new string[] { " " };
                            char[] c = new char[] { ' ' };
                            str = sr.ReadLine();
                            arr = str.Split(c);

                            data d = new data();
                            d.date = arr[0];
                            d.time = arr[1];
                            d.lat = Convert.ToDouble(arr[3]);
                            d.lon = Convert.ToDouble(arr[4]);
                            d.depth = arr[7];
                            d.mag = arr[8];


                        }



now i want to store those array values into access database, how do i achieve this?
Posted
Updated 28-Jul-13 6:17am
v3
Comments
[no name] 28-Jul-13 12:13pm    
"how do i proceed", read www.whathaveyoutried.com
Boipelo 28-Jul-13 12:27pm    
Your problem is not properly explained. I guess "data" is your class - add the save/updates method there, and call it after d.mag = arr[8].
ridoy 28-Jul-13 12:45pm    
you can't clearly explain what you want.

1 solution

Instead loading text file into array, read this file direct into Access database using JET 4.0. OLEDB drivers: Reading Text files into Access with ASP.NET[^]
 
Share this 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