|
-
Jun 22nd, 2006, 08:54 PM
#1
Thread Starter
Hyperactive Member
[2005] Loading data on datagridview
VB Code:
Dim dbReader As OleDbDataReader = dbCommand.ExecuteReader
ComboBox1.Items.Clear()
While (dbReader.Read)
ComboBox1.Items.Add(dbReader("PatientID"))
End While
I am using this code to load the combobox with all PatientID on a certain table of my access database.It was doing fine and now want to load the data in a datagridview.how can I possibly do this?One more thing, what if I also want to load the Name("PatientName") in the grid along with its ID?thanks in advance....
Last edited by aldrean; Jun 22nd, 2006 at 08:55 PM.
Reason: typo error
-
Jun 22nd, 2006, 09:11 PM
#2
Re: [2005] Loading data on datagridview
If you want to dispay data in a grid then I suggest that you don't use a data reader. I'd suggest using a data adapter to Fill a DataTable and then simply assign the DataTable to the grid's DataSource property.
-
Jun 22nd, 2006, 09:17 PM
#3
Thread Starter
Hyperactive Member
Re: [2005] Loading data on datagridview
i had tried using the wizard for the grid's datasource, using the dataset as my source, I just find it too slow to load the grid(about 8seconds) for a merely 20K records.Did it really had to be that long?That is the reason why I wanted for another option, or somebody can please let me know how can I possibly minimize the loading time?
-
Jun 17th, 2007, 10:05 PM
#4
Addicted Member
Re: [2005] Loading data on datagridview
 Originally Posted by jmcilhinney
If you want to dispay data in a grid then I suggest that you don't use a data reader. I'd suggest using a data adapter to Fill a DataTable and then simply assign the DataTable to the grid's DataSource property.
instead of assigning the datasource to DataTable .. is it ok to assign the datasource to DataSet?
-
Jun 17th, 2007, 10:10 PM
#5
Re: [2005] Loading data on datagridview
 Originally Posted by mizee
instead of assigning the datasource to DataTable .. is it ok to assign the datasource to DataSet?
Do you actually understand what a DataSet is? A DataSet is not a substitute for a DataTable. A DataSet cannot be of any use unless it contains one or more DataTables because it's the DataTables that contain the data. You ALWAYS have to bind your controls to a DataTable one way or another. If your DataTable is in a DataSet then you can bind it directly:
vb.net Code:
myControl.DataSource = myDataSet.Tables("table name here")
or indirectly:
vb.net Code:
myControl.DataMember = "table name here"
myControl.DataSource = myDataSet
-
Jun 17th, 2007, 10:16 PM
#6
Addicted Member
Re: [2005] Loading data on datagridview
 Originally Posted by jmcilhinney
Do you actually understand what a DataSet is? A DataSet is not a substitute for a DataTable. A DataSet cannot be of any use unless it contains one or more DataTables because it's the DataTables that contain the data. You ALWAYS have to bind your controls to a DataTable one way or another. If your DataTable is in a DataSet then you can bind it directly:
vb.net Code:
myControl.DataSource = myDataSet.Tables("table name here")
or indirectly:
vb.net Code:
myControl.DataMember = "table name here"
myControl.DataSource = myDataSet
ok got it. Thanx.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|