|
-
Aug 10th, 2011, 11:43 AM
#1
Thread Starter
New Member
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!
-
Aug 10th, 2011, 12:44 PM
#2
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:
 Originally Posted by MSDN
There are other ways to do it, but this is probably the most simple.
-
Aug 10th, 2011, 01:15 PM
#3
Thread Starter
New Member
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
-
Aug 10th, 2011, 01:29 PM
#4
Thread Starter
New Member
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..
-
Aug 10th, 2011, 01:35 PM
#5
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.
-
Aug 10th, 2011, 01:41 PM
#6
Re: Help with console application
 Originally Posted by lorxx071
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.
-
Aug 10th, 2011, 02:23 PM
#7
Thread Starter
New Member
Re: Help with console application
You are correct. I am dealing with a tab delimiter.
-
Aug 10th, 2011, 03:12 PM
#8
Re: Help with console application
 Originally Posted by lorxx071
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
-
Aug 10th, 2011, 03:26 PM
#9
Thread Starter
New Member
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
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|