Question : Can I populate datagridview from data reader rather than data adapter

I'm using this code to popluate a datagridview from a database.
There can be about 40000 rows.  Is there a more efficient way of doing this eg using a data reader instead of an adapter?
Code Snippet:
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
dim con1 As New SqlClient.SqlConnection()
Dim dtF2 As New DataTable
Dim cmd1 As New SqlClient.SqlCommand

connectionString = "XXXX"
con1.ConnectionString = connectionString
con1.Open()
cmd1.Connection = con1
cmd1.CommandText = "StoredProcName"
cmd1.CommandType = CommandType.StoredProcedure
cmd1.Parameters.Clear()
cmd1.ExecuteNonQuery()
adapter.SelectCommand = cmd1
adapter.Fill(dtF2)
Grid2.DataSource = dtF2

Answer : Can I populate datagridview from data reader rather than data adapter





         DataTable dtF2= new DataTable();
        dtF2.Load(myReader);
       
       Grid2.DataSource = dtF2
Random Solutions  
 
programming4us programming4us