Solved

Is there a command to import a text file into Microsoft SQL Server 2008 using ASP.NET with Visual Studio 2010 using C# with .NetFramework 4.0 ?

Posted on 2016-08-08
3
58 Views
Last Modified: 2016-08-09
I have an Access application that uses Access as the front end and back end.

It has an Import command button that executes the following command:

DoCmd.TransferText acImportFixed, "monthlychecks spec", "importMonthlyChecks", filenm, False

Is there a command to import a text file into Microsoft SQL Server 2008 using ASP.NET with Visual Studio 2010 using C# with .NetFramework 4.0 ?
0
Comment
Question by:zimmer9
  • 2
3 Comments
 
LVL 12

Expert Comment

by:funwithdotnet
ID: 41748242
Not exactly, but it's easy to do. Read the file with a StreamReader, parse it based on the format, then use SqlCommand.ExecuteNonQuery() to insert the data.

If you want example code to parse a tab-delimited, CSV or fixed-length file, there are plenty of examples available, probably on this site.

You could StreamReader.ReadLine() and a Substring to parse the columns & values for a fixed-length file, for example.

Good luck!
0
 
LVL 12

Assisted Solution

by:funwithdotnet
funwithdotnet earned 250 total points
ID: 41748245
I almost forgot - once you know how to process the files, just put the whole thing in a method and viola! you have your command.
0
 
LVL 9

Accepted Solution

by:
Prakash Samariya earned 250 total points
ID: 41748295
0

Featured Post

Master Your Team's Linux and Cloud Stack!

The average business loses $13.5M per year to ineffective training (per 1,000 employees). Keep ahead of the competition and combine in-person quality with online cost and flexibility by training with Linux Academy.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Wouldn’t it be nice if you could test whether an element is contained in an array by using a Contains method just like the one available on List objects? Wouldn’t it be good if you could write code like this? (CODE) In .NET 3.5, this is possible…
It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
This video shows how to quickly and easily add an email signature for all users on Exchange 2016. The resulting signature is applied on a server level by Exchange Online. The email signature template has been downloaded from: www.mail-signatures…

808 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question