Improve company productivity with a Business Account.Sign Up

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 91
  • Last Modified:

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 ?

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
zimmer9
Asked:
zimmer9
  • 2
2 Solutions
 
funwithdotnetCommented:
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
 
funwithdotnetCommented:
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
 
Prakash SamariyaIT ProfessionalCommented:
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now