Forums
New posts
Search forums
What's new
New posts
New profile posts
Latest activity
Members
Current visitors
New profile posts
Search profile posts
C# Community
Log in
Register
What's new
Search
Search
Search titles only
By:
New posts
Search forums
Menu
Log in
Register
Install the app
Install
VB.NET
VB.NET General Discussion
Data Grid Replaces the next File Data instead of copying after the first file
JavaScript is disabled. For a better experience, please enable JavaScript in your browser before proceeding.
You are using an out of date browser. It may not display this or other websites correctly.
You should upgrade or use an
alternative browser
.
Reply to thread
Message
[QUOTE="meho2021, post: 185224, member: 71470"] Dear All I am having a code which copies excel files data from specific folder and paste them to Data Grid view. The Data Grid Read all data of all files but the problem that it does not give the data of the first file and the second file respectively but it replaces the first file data with the second file data as a result, it always gives the last file data only instead of giving the first and the second file data together, I know there is something missing in my code which I do not know Here is my code [CODE=vbnet]Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click If FolderBrowserDialog1.ShowDialog = System.Windows.Forms.DialogResult.OK Then DataGridView1.Rows.Clear() Dim Directory = FolderBrowserDialog1.SelectedPath Dim Files() As System.IO.FileInfo Dim DirInfo As New System.IO.DirectoryInfo(Directory) Files = DirInfo.GetFiles("*", IO.SearchOption.AllDirectories) For Each File In Files Dim MyConnection As System.Data.OleDb.OleDbConnection Dim MyCommand As System.Data.OleDb.OleDbDataAdapter Dim DtSet As DataSet MyConnection = New System.Data.OleDb.OleDbConnection ("Provider=Microsoft.Jet.OLEDB.4.0;Data Source='" & File.FullName & "'; Extended Properties=Excel 4.0;") MyCommand = New OleDbDataAdapter("select SN, BarMark, Diameter, Length, Quantity ,BBSName from [SCHEDULE$]", MyConnection) MyCommand.TableMappings.Add("Table", "Test") DtSet = New DataSet MyCommand.Fill(DtSet) DataGridView1.DataSource = DtSet.Tables(0) MyConnection.Close() Next End If End Sub[/CODE] Appreciate your support since this is important to my work Thanks, Regards [/QUOTE]
Insert quotes…
Verification
Post reply
VB.NET
VB.NET General Discussion
Data Grid Replaces the next File Data instead of copying after the first file
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.
Accept
Learn more…
Top
Bottom