Microsoft Visual Basic (VB) is a programming language that is easy to learn and use. VB is used to develop user-friendly Windows applications. One common task in the programming world is to move file information from one location to another. You can easily save information in a text file to a Microsoft Access database table using Microsoft OLE DB. Access is a relational database application included in the Microsoft Office suite.
- Skill level:
Other People Are Reading
Things you need
- Microsoft Office Access 2003
- Microsoft Notepad
- Microsoft Visual Basic 2010 Express
Open "Notepad" and type "NAME, AGE, CITY" in the first line.
Type "JOHN, 25, WATAUGA" in the second line.
Save the file to "C:\" as "myTextFile.txt".
Open Microsoft Access and create a new database. Save your database to "C:\" as "test.mdb".
Start Microsoft Visual Basic 2010 Express, select the "File" menu and click "New Project...". Click on "Windows Forms Application" and select "OK."
Double-click "Button" on the "Toolbox" menu to add a new button to "Form1." Double-click "Button1" to start writing your code under "Form1.vb."
Type "Imports System.Data.OleDb" in the first line of "Form1.vb."
Type the following inside the "Button1_Click" subroutine to define your connection and command:
Dim oledbConn As New OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\test.mdb")
Dim oledbCommand As New OleDbCommand("SELECT * INTO [myTextFile] FROM [Text;Database=C:\;Hdr=Yes].[myTextfile.txt]", oledbConn)
Type the following to open the connection and execute the command then close the connection:
Press "F5" to run your program and click "Button1" to execute the subroutine.
- 20 of the funniest online reviews ever
- 14 Biggest lies people tell in online dating sites
- Hilarious things Google thinks you're trying to search for