Results 1 to 9 of 9

Thread: Help with console application

  1. #1

    Thread Starter
    New Member
    Join Date
    Aug 2011
    Posts
    5

    Exclamation Help with console application

    I am trying to create a console application that does the following:
    1) read a text file
    2) Save the content over to a SQL Server database
    3) Use command line arguments to allow user to specify any delimited file
    Thanks for looking!

  2. #2
    Master Of Orion ForumAccount's Avatar
    Join Date
    Jan 2009
    Location
    Canada
    Posts
    2,802

    Re: Help with console application

    Welcome to the forums.

    Contrary to popular belief, we don't just post applications for users. Generally we just help you fix something that's broken or answer a question you have. Having said that, you haven't actually provided either. Secondly, each separate question should be posted in a new thread. Thirdly, all of those questions can be answer by searching on this forum. 2 of 3 are amongst the most popular questions asked on this forum. For the third point, it gets a little bit more complicated, because of this I have provided you a relevant link:
    Quote Originally Posted by MSDN
    There are other ways to do it, but this is probably the most simple.

  3. #3

    Thread Starter
    New Member
    Join Date
    Aug 2011
    Posts
    5

    Re: Help with console application

    I apologize,

    I have an idea of how to do the arguments; however, my main problem is trying to read the content of a text file and saving it into an SQL Database.


    Thanks

  4. #4

    Thread Starter
    New Member
    Join Date
    Aug 2011
    Posts
    5

    Re: Help with console application

    So far, I have declared all the column names
    Code:
        Private _id As Integer
        Private _firstName As String
        Private _lastName As String
        Private _street As String
        Private _city As String
        Private _state As String
        Private _zip As String
        Private _ccName As String
        Private _ccNumber As String
        Private _phone As String
    I have also declared the property for each individual:
    Code:
        Public Property ID() As Integer
            Get
                Return _id
            End Get
            Set(ByVal value As Integer)
                _id = value
            End Set
        End Property
    
    etc..

  5. #5
    Karen Payne MVP kareninstructor's Avatar
    Join Date
    Jun 2008
    Location
    Oregon
    Posts
    6,713

    Re: Help with console application

    Adding to FA post.

    Another good thing to provide with your question is the version of Visual Studio you are currently working with along with the Framework version.

    Begin with something like.
    I am currently using VS2010 with Framework 4

    The reason behind this is say you are using VS2005 someone may propose a solution that is not supported under VS2005 but instead requires VS2008 or higher and if the version of VS and Framework was indicated the person proposing a solution would provide something for your current environment.

    If the version of VS you are using is the Express edition please indicate this also.

    As ForumAccount mentioned lots of similar questions here for parsing files. Do not find one a go with it but instead examine several and see what feels right for you as some may be more advance than you need or overly complex that could easily be done with less code. Make sure to check out TextFieldParser which is supported from VS2005-VS2010 (Framework 2x to Framework 4x). This is not to say TextFieldParser correct for you but instead I mention it because many developers do not know about it.

  6. #6
    Karen Payne MVP kareninstructor's Avatar
    Join Date
    Jun 2008
    Location
    Oregon
    Posts
    6,713

    Re: Help with console application

    Quote Originally Posted by lorxx071 View Post
    3) Use command line arguments to allow user to specify any delimited file
    You should consider when saying "any delimited file" means you must then figure out the delimitor which adds to the complexity of reading a file. For instance if the delimitor is unknown and you need to make an educated guess there is a risk of lose of data if the guess was tab delimited and the file was comma delimited etc.

  7. #7

    Thread Starter
    New Member
    Join Date
    Aug 2011
    Posts
    5

    Re: Help with console application

    You are correct. I am dealing with a tab delimiter.

  8. #8
    Karen Payne MVP kareninstructor's Avatar
    Join Date
    Jun 2008
    Location
    Oregon
    Posts
    6,713

    Re: Help with console application

    Quote Originally Posted by lorxx071 View Post
    You are correct. I am dealing with a tab delimiter.
    Take a look at the following project which is not a console application but shows how to use TextFieldParser against a tab delimited file with known amount of columns. Study the code until it makes sense as simply adapting code without understanding it is not a good thing as eventually if there is a problem you will be held for ransom by your code rather than saying I understand the problem and how to fix it.

    http://kevininstructor.home.comcast....ieldParser.zip

  9. #9

    Thread Starter
    New Member
    Join Date
    Aug 2011
    Posts
    5

    Re: Help with console application

    Thank you for your help! Very appreciated!

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width