Hi Akram.19,
Please refer below sample.
DataBase
Note: For this example I have used of Northwind database that you can download using the link given below.
Download Northwind Database
Namespaces
C#
using System.Data.SqlClient;
using System.Configuration;
VB.Net
Imports System.Data.SqlClient
Imports System.Configuration
Code
C#
private void Form1_Load(object sender, EventArgs e)
{
string query = "SELECT Top 3 CustomerID, ContactName, Country FROM Customers;";
query += "SELECT Top 3 EmployeeId, FirstName, Country FROM Employees";
string conString = ConfigurationManager.ConnectionStrings["constr"].ConnectionString;
using (SqlConnection con = new SqlConnection(conString))
{
using (SqlCommand cmd = new SqlCommand(query, con))
{
using (SqlDataAdapter sda = new SqlDataAdapter(cmd))
{
using (DataSet ds = new DataSet())
{
sda.Fill(ds);
dgvCustomers.DataSource = ds.Tables[0];
dgvEmployees.DataSource = ds.Tables[1];
}
}
}
}
}
VB.Net
Private Sub Form1_Load(ByVal sender As Object, ByVal e As EventArgs) Handles Me.Load
Dim query As String = "SELECT Top 3 CustomerID, ContactName, Country FROM Customers;"
query += "SELECT Top 3 EmployeeId, FirstName, Country FROM Employees"
Dim conString As String = ConfigurationManager.ConnectionStrings("constr").ConnectionString
Using con As SqlConnection = New SqlConnection(conString)
Using cmd As SqlCommand = New SqlCommand(query, con)
Using sda As SqlDataAdapter = New SqlDataAdapter(cmd)
Using ds As DataSet = New DataSet()
sda.Fill(ds)
dgvCustomers.DataSource = ds.Tables(0)
dgvEmployees.DataSource = ds.Tables(1)
End Using
End Using
End Using
End Using
End Sub
Screenshot