I am a newbie to VB .NET and have a project where I need to programmatically read comma-delimited text files (generated once every 5 minutes), perform some calculations on the data columns before sending some of the returned values to another application. As an intermediate step and to learn more about the process, I am trying to enable the end user to select a text file, populate the datagridview with the file's data and display some calculations on the same form (in textboxes...sum, average, etc.). I can populate and view the data for one file manually, but I cannot seem to get the data to display in the datagridview programmatically, based on the user-selected file.
The code I have so far is as follows:
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
TextBox1.Text = OpenFileDialog1.FileName
Dim selectedfile As String = OpenFileDialog1.FileName
Dim ConnectionString As String
Dim SQLString As String
ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=c:\temp;Extended Properties=""Text;HDR=NO;"""
SQLString = "Select * from " & selectedfile
Dim ConnectionText As New OleDb.OleDbConnection
ConnectionText.ConnectionString = ConnectionString
Dim AdapterText As New OleDb.OleDbDataAdapter(SQLString, ConnectionText)
Dim DataSetText As New DataSet("TextFiles")
DataGridView1.DataSource = DataSetText
Thanks for your assistance...I think if I get some help getting the datagridview populated and the summary statistics calculated I should be good to go.