|
web
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
Convert Access Table to Text File using VBhave a MS access table and I want to export it to comma delimited
text file. How do I do this programmatically using VB.NET or C#? Thanks for any help in advance. Raju Hi,
For exporting Access table data, you need to read the records in DataReader and then write these records in .CSV file one by one.... You need to follow these steps: 1. Open the file for writing (in append mode) with file stream writer: Dim sw As New StreamWriter("FileName.csv", True) 2. Read table in DataReader. 3. Loop throught the data reader, Read record in string variable, Write in File. Dim strRecord as string Do While myReader.Read() ' Use ',' (comma) as seperator when you are writing field values in file. strRecord = myReader("FIELD1") & "," & myReader("FIELD2") & "," & myReader("FIELD2")...... ' Write record in file. sw.WriteLine(strRecord ) Loop I don't know if there is some other way to do this. Regards, Pragati Palewar Palewar Techno Solutions Windows & Windows Mobile Software Development Nagpur, India http://www.palewar.com On 1 Sep 2006 23:16:51 -0700, raju5***@gmail.com wrote:
¤ have a MS access table and I want to export it to comma delimited ¤ text file. How do I do this programmatically using VB.NET or C#? ¤ ¤ Thanks for any help in advance. You can do this rather easily with ADO.NET and SQL: Dim AccessConn As New System.Data.OleDb.OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;" & _ "Data Source=e:\My Documents\db1.mdb") AccessConn.Open() Dim AccessCommand As New System.Data.OleDb.OleDbCommand("SELECT * INTO [Text;HDR=No;DATABASE=e:\My Documents\TextFiles].[td.txt] FROM Table_3", AccessConn) AccessCommand.ExecuteNonQuery() AccessConn.Close() Paul ~~~~ Microsoft MVP (Visual Basic)
Structures, Classes for storing data
Changing the text of a Command Button using SetWindowText Is Thread.Abort() blocking until Thread has exited? Stream Validating emails how to add dynamic tooltip when dragging scrollbar of datagridview Appending text to an array of textboxes what is wrong with this StreamWriter, FileStream throwing uncatchable NullReferenceException Is there a Library or component for creating HTML? |
|||||||||||||||||||||||