Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 4021156
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T10:19:01+00:00 2026-05-20T10:19:01+00:00

Work on VS08 C# window . I have txt file . After read the

  • 0

Work on VS08 C# window. I have txt file . After read the file, I need to store the file information in database. My SQL Server database table structure is below:

CREATE TABLE [dbo].[StoreTxtValues]
(
  [PortCode] [int] (80) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL,
  1)[Vessel] [varchar] (800) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL,
  2)[Voyage] [varchar] (800) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL,
  3)[Sailed] [datetime] NOT NULL,
  4)[Carrier] [varchar] (800) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL,  
  5)[LoadingContainer] [varchar] (800) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL,  
  6)[DischargeSeal] [varchar] (800) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL,
  7)[rowValue] [varchar] (8000) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL,

)

1),2),3),4),5),6),7)

Please see those numbers in the picture. I need help to store the data as I describe on it. Any suggestion will be accepted. Thanks in advance.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-20T10:19:01+00:00Added an answer on May 20, 2026 at 10:19 am

    Parse the file line by line to get the information you need. Use System.IO.FileStream or StreamReader to load the data, and then you can process it as needed. Save it to the database.

    Here’s a quick example for using StreamReader from here.

    using (StreamReader sr = new StreamReader(path))   
    {  
        while (sr.Peek() >= 0)   
        {  
            string lineFromFile = sr.ReadLine();  
            //now parse the string lineFromFile and get the information you need  
        }  
    } 
    

    I might add that it might be helpful to create objects to represent the various pieces of data you need to store. That object can then make it easier to deal with the data, saving it to a database etc.

    Parsing the string (this assumes the files are all the same exact format, i.e. same lines of information).

    Keep track of what line you are on.

    string[] myFile = File.ReadAllLines(@"C:\file.txt");
    
    var lineCount = myFile.Length;
    
         for(i=0; i<lineCount; i++)  
         {
              switch(i)
              {
                   case 0:
                       //parse line 0
                       break;
                   case 1:
                       //parse line 1
                       break;
                   case 2:
                       //parse line 2
                       break;
                   //and so on until you get to the line that begins the regular "records" part of the file
              }
    
              if(i >= 10) //assumes line 10 is where the regular "records" start
              {
                  //parse the record like so
                  string[] columns = myFile[i].Split('\t'); //this assumes your columns are separated by a tab. If it's a space you would use myFile[i].Split(' '), etc. 
                  //now you have an array with all your columns
                  foreach(string column in columns)
                  {
                       //now do what you want with the information
    
                  }
              }
         }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I work with SQL Server database with ODBC, C++. I want to detect modifications
work on SQL Server 2000. want to Automated Email Notifications using SQL Server Job
Work on C#, in one of my application I need to get the SQL
work on Sql server 2000. i want to get the current server date and
At work, I have a large table (some 3 million rows, like 40-50 columns).
work on sql-server-2005 SELECT A.specific_customization_id , A.customization_id , A.customization_value , A.customization_price , A.customization_cost ,
I work on Asp.Net VS08 C#. Clicking on Button want to show popup. popup
Work on asp.net vs05. I have three type of value Like:IsDesign,IsPrinting,IsInstall they are bit
Work on this small test application to learn threading/locking. I have the following code,
Work on the following website: http://cetcolor.com The masthead graphic with the Read About It

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.