sir please i want a c# code that reads from the txt file and save it to database...

Recommended Answers

All 4 Replies

What have you got so far?

I will happily help you with errors when stuck but I don't get paid to write the code for you, neither does anyone else on this site.

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.IO;
using System.Diagnostics;

n

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.IO;
using System.Diagnostics;

namespace ConsoleApplication1
{
    class Program
    {
        static void Main(string[] args)
        {
            List<String> table = new List<string>();
            List<String[]> columns = new List<string[]>();
            List<String[]> contents = new List<string[]>();
            try
            {
                String path = @"E:\McdonaldsMenu.txt";
                using (StreamReader sr = new StreamReader(path))
                {
                    String line;
                    // Read and display lines from the file until the end of 
                    // the file is reached.
                    while ((line = sr.ReadLine()) != null)
                    {
                        table.Add(line);
                        if ((line = sr.ReadLine()) != null)
                        {
                            String[] _column = line.Split(new Char[] { '|' });
                            columns.Add(_column);
                        }
                        if ((line = sr.ReadLine()) != null)
                        {
                            String[] _content = line.Split(new Char[] { '|' });
                            contents.Add(_content);
                        }
                    }
                }
            }
            catch (Exception e)
            {
                Console.WriteLine("The file could not be read:");
                Console.WriteLine(e.Message);
            }
        }
    }
}

sir here is the code it jst read frm txt file.....and i dont know how to make this link with database ....plx help i will b very thank full to u....

Whats the database structure like?

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.