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 6672199
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T03:28:48+00:00 2026-05-26T03:28:48+00:00

I am brand new to this community. I am also somewhat new to programming

  • 0

I am brand new to this community. I am also somewhat new to programming and this is a noob question. If my wording is bad or any members have any advice to give a newbie please do! Anyway, here I go!

The following method (although its obvious), grabs a file and inserts it into a database table (KC_Reply_Shipped), (or cancels into another table), also obvious. The file looks something like this

YYYY847583 blahblahblah blah blahahasdf blah blah

XXX8343445 ” ” ” “

XXX8976556 ” ” ” “

However, I do NOT want to insert the YYYY. I can not help that the File has this, because it is out of my control. But I DO want the XXX. Sometimes the file will have YYYY and sometimes it will not.

although this seems so easy, me being noob, I get confused on the wording because I already have a while statement and the method is boolean. FYI this is only for fun and experimentation. Nothing serious. Any help or answer would be greatly appreciated. Thank you^2 in advance!

    private bool InsertIntoDatabase(FileInfo file)
    {
        string table = "KC_Reply_Shipped";
        string line;
        StreamReader reader = new StreamReader(file.FullName);
        try
        {
            Database db = new Database();
            ShippedOrders = new List<string[]>();
            CancelledOrders = new List<string[]>();
            while ((line = reader.ReadLine()) != null)
            {
                string[] temp = GetFileDataForInsert(line);
                temp[temp.Length - 1] = file.Name.Substring(0, file.Name.Length - 4);
                if (temp[1] == "30")
                {
                    table = "KC_Reply_Cancelled";
                    CancelledOrders.Add(temp);
                    db.UpdateOrderToCancelled(temp[0]);
                }
                else
                {
                    ShippedOrders.Add(temp);
                    db.UpdateOrderToShipped(temp[0]);
                    db.UpdateOrderTrackingNumber(temp[10]);
                    db.UpdateOrderNotes(temp);
                }
                db.BatchInsert(table, temp);
            }
        }
        catch (Exception e)
        {
            errorMsg = e.Message;
            return false;
        }
        finally
        {
            reader.Close();
        }
        return true;
    }
  • 1 1 Answer
  • 3 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-26T03:28:48+00:00Added an answer on May 26, 2026 at 3:28 am

    You could try something like the following to check the start of the line and the make a decision from there:

    if(!line.StartsWith("YYYY"))
    {
         //....do stuff here
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Brand new to Python (and programming in general), if this is simple and/or answered
Ok so this is a brand new snag I have run into. I am
As a preface to this question: I am brand new to Rails development (and
I'm brand new to Ruby/Rails/RSpec, and hopefully this is a dumb/simple question. I'm currently
I am brand new to Subversion and have been told that this is the
I'm brand new to xsl so this is probably a very simple question. I
This seems really simple but Im brand new to JavaScript. I have a link
I have created a brand new WCF Service. I created this service by just
This is probably a dumb question, but I'm brand new to git and am
i'm creating a brand new masterpage with VS2010 Beta 2 and I get this

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.