Transferring data from one DataGridView to another - Tutoria
Posted: Fri Mar 11, 2011 6:37 pm
Hello guys.
Here is my new tutorial.
Hope you like it!
Ok lets start the tutorial now.
1. Open VB.NET and create a new Windows Forms Application.
2. Rename your Form to GridDemo.
3. Create One Database File named "DataBaseFile" in Microsoft SqlServer Management Studio Express.
4. Create any 1 Table in DatabaseFile.
5. Now come to the Windows Form.
6. Take Two DataGridView (named DataGridView1 & DataGridView2), One Button (named cmdShift) on the Form.
7. Go to the code view and delete all code and put this code -
Hope you liked my tutorial!
If you like my tutorial then please give me +rep!
Credits : VBDotNetHeaven
Here is my new tutorial.
Hope you like it!

Ok lets start the tutorial now.
1. Open VB.NET and create a new Windows Forms Application.
2. Rename your Form to GridDemo.
3. Create One Database File named "DataBaseFile" in Microsoft SqlServer Management Studio Express.
4. Create any 1 Table in DatabaseFile.
5. Now come to the Windows Form.
6. Take Two DataGridView (named DataGridView1 & DataGridView2), One Button (named cmdShift) on the Form.
7. Go to the code view and delete all code and put this code -
Code: Select all
And you are done!! Imports System.Data.SqlClient
Public Class DataSetDemo
Dim Conn As New SqlConnection("Data Source=Studio\SqlExpress; Initial Catalog= DataBaseFile;Integrated Security=True") 'Create new SqlConnection String
Dim Dset As New DataSet() 'Create new Instance of DataSet Class
Dim adapt As SqlDataAdapter 'Create new Instance of SqlDataAdapter Class
Dim cmd As SqlCommand 'Create new Instance of SqlCommand Class
Public Sub UpdateGrid() 'Update the DataSource of DataGridView1 and DataGridView2
Dset.Clear() 'Clear the Dataset Contents
adapt = New SqlDataAdapter("Select * from Information", Conn)
adapt.Fill(Dset, "Information") 'Add the "Information" table to DataSet
'Display the content of "Information" table to DataGridView
DataGridView1.DataSource = Dset.Tables("Information")
adapt = New SqlDataAdapter("Select * from Shift_Info", Conn)
adapt.Fill(Dset, "Shift_Info") 'Add the "Shift_Info" table to DataSet
'Display the content of "Shift_Info" table to DataGridView
DataGridView2.DataSource = Dset.Tables("Shift_Info")
End Sub
Private Sub GridDemo_Load(ByVal sender As System.Object, _
ByVal e As System.EventArgs) Handles MyBase.Load
UpdateGrid()
End Sub
End Class

Hope you liked my tutorial!
If you like my tutorial then please give me +rep!

Credits : VBDotNetHeaven