Hi,
I am working in reconciliation project while uses multiple text file .
Currently i completed one step in this project and retrieve the text file in data table and data grid .
I have a problem with link database with VB.net and append all data in text files in database tables .
Any help please
Here is the code
Code:
Public Class Form1
Dim con As New OleDb.OleDbConnection
Public Sub New()
InitializeComponent()
Dim scon As String = String.Empty, scom As String = String.Empty
Dim con As OleDb.OleDbConnection = Nothing, com As OleDb.OleDbCommand = Nothing, rdr As OleDb.OleDbDataReader = Nothing
Dim sFileName As String = String.Empty
Dim dt As Data.DataTable = Nothing, r As DataRow = Nothing
Try
sFileName = "C:\test\record.txt"
scon = "Provider=Microsoft.Jet.OleDb.4.0;Data Source=" & IO.Path.GetDirectoryName(sFileName) & ";Extended Properties='Text;HDR=Yes;Schema=schema.ini;';"
scom = "SELECT * FROM " & sFileName
con = New OleDb.OleDbConnection(scon)
con.Open()
com = New OleDb.OleDbCommand(scom, con)
rdr = com.ExecuteReader()
dt = New Data.DataTable
dt.Load(rdr)
Me.DataGridView1.DataSource = dt
TextBox1.Text = D
Catch ex As Exception
MsgBox(ex.Message, MsgBoxStyle.Exclamation, "Error...")
Finally
rdr.Close()
com.Dispose()
con.Close()
con.Dispose()
End Try
End Sub