ARTICLE

Accessing Text File Databases in ADO.NET

Posted by Dinesh Beniwal Articles | ADO.NET in VB.NET June 23, 2010
In this article I will explain about Accessing Text File Databases in ADO.NET.
 
Reader Level:

HTML clipboard

To test database connectivity, you can export the Employees table of the Northwind database using the File > Export option of Access 2000. In this section, I'll export a table to a text file, and I'll show you how to use it using the ODBC data adapter.
 
Exporting an Access Table to a Text File
 
You can export an Access database table to a text file using the Export option. As you can see from figure 11-22, I selected the Employees table and chose file > Export.
 
Note: You can also select the Export option by right-clicking on the table.
 
Figure-11.22.gif
 
Figure 11-22: Exporting the employees table of Northwind.mdb
 
The next dialog box lets you pick a path and filename you want to export. There are many export options are available. As you can see from figure 11-23, I selected the Text files option, left the exported filename as Employees, and saved the file to the C:\root directory. 
 
Figure-11.23.gif
 
Figure 11-23: Selecting a path of exporting file
 
Now, the Export Text Wizard lets you define the format of the text file. A dialog box lets you select either delimited or fixed width (see Figure 11-24).
 
Figure-11.24.gif
 
Figure 11-24: Export Text Wizard options
 
You can also select the Advanced option to set more options (see Figure 11-25).
 
Figure-11.25.jpg
 
Figure 11-25: The Advanced option of Export Text Wizard
 
The next screen lets you pick the delimiter including comma, tab, semicolon, space, and others. I left the Comma option checked (see Figure 11-26).
 
Figure-11.26.gif
 
Figure 11-26: Delimiter options of Export Text Wizard
 
I also checked the Include Field Names on first Row check box. This option adds the first row of the text file as field names. 
 
The last page asks you the filename (see Figure 11-27).
 
Figure-11.27.jpg
 
Figure 11-27: Filename page of the Export Text Wizard
 
Now click the finish button. When the wizard is done exporting, you'll see a message saying the export is finished. Click OK and close Access. 
 
Now view C:\Employees.txt (see figure 11-28).
 
Figure-11.28.gif
 
Figure 11-28: Exported Employees.txt file from Northwind.mdb
 
Conclusion
 
Hope this article would have helped you in understandingAccessing Text File Databases in ADO.NET. See my other articles on the website on ADO.NET.

Login to add your contents and source code to this article
share this article :
post comment
 
Become a Sponsor
PREMIUM SPONSORS
  • Finally – a virtual platform that delivers next-generation Windows Server 2008 Hyper-V virtualization technology from a managed hosting partner you can truly depend on. Visit www.maximumasp.com/max for a FREE 30 day trial. Hurry offer ends soon. Climb aboard the MaxV platform and take advantage of High Availability, Intelligent Monitoring, Recurrent Backups, and Scalability – with no hassle or hidden fees. As a managed hosting partner focused solely on Microsoft technologies since 2000, MaximumASP is uniquely qualified to provide the superior support that our business is built on. Unparalleled expertise with Microsoft technologies lead to working directly with Microsoft as first to offer IIS 7 and SQL 2008 betas in a hosted environment; partnering in the Go Live Program for Hyper-V; and product co-launches built on WS 2008 with Hyper-V technology.
    The leading .NET charting control now features PDF, Flash and Silverlight export, visualization of large datasets and more. Deliver true charting functionality to your BI, Scorecard, Presentation or Scientific apps. Download evaluation now.
6 Months Free & No Setup Fees ASP.NET Hosting!
Become a Sponsor