|
-
Jul 5th, 2006, 01:46 AM
#1
Thread Starter
Addicted Member
[2005] Read From A Dataset Instead Of DataReader
Dear Folks,
i created this thread because i got no help on something setting me back that i presented in another thread. In that thread, someone suggested that i use a dataset instead of a Datareader.
I am trying to populate a form using a DataReader....how can i populate my form by simply using a dataset.
You will excuse me, i know how to create one,fill it and use it but i dont know how to populate each control on my form with a corresponding field of the record accessed by the dataset.
Any Idea will be highly appreciated.
-
Jul 5th, 2006, 02:03 AM
#2
Re: [2005] Read From A Dataset Instead Of DataReader
Add a BindingSource to your form in the designer. The following steps can be done in the designer or in code.
Bind your DataTable to the BindingSource using its DataSource and, optionally, DataMember properties. The BindingSource now acts a way to view the data in the table.
Bind your controls to the BindingSource using their DataBindings property, e.g.
VB Code:
myTextBox.DataBindings.Add("Text", myBindingSource, "ColumnName")
You can now set the Position property of the BindingSource to a record index and every bound control will update. You can then get a DataRowView object for the current record through the Current property.
-
Jul 5th, 2006, 02:05 AM
#3
Thread Starter
Addicted Member
Re: [2005] Read From A Dataset Instead Of DataReader
Thanks JMC...i wish databindings were better for me!! Alas...i have never liked using them aand i dont use them at all. Is there any other way?
-
Jul 5th, 2006, 02:10 AM
#4
Thread Starter
Addicted Member
Re: [2005] Read From A Dataset Instead Of DataReader
I am taking a chatter to a remote location i will be back online in an 1 and 1/2 hrs time.
-
Jul 5th, 2006, 02:17 AM
#5
Re: [2005] Read From A Dataset Instead Of DataReader
 Originally Posted by skea
Thanks JMC...i wish databindings were better for me!! Alas...i have never liked using them aand i dont use them at all. Is there any other way?
Of course: do it all manually. It's up to you, but you're asking how to populate your controls so that implies you wanted some of the work done for you. If that's not the case then just set the appropriate properties as you normally would. Data binding IS the automatic way. If you don't like using them then don't. Plain and simple.
-
Jul 5th, 2006, 03:19 AM
#6
Lively Member
Re: [2005] Read From A Dataset Instead Of DataReader
 Originally Posted by skea
Dear Folks,
i created this thread because i got no help on something setting me back that i presented in another thread. In that thread, someone suggested that i use a dataset instead of a Datareader.
I am trying to populate a form using a DataReader....how can i populate my form by simply using a dataset.
You will excuse me, i know how to create one,fill it and use it but i dont know how to populate each control on my form with a corresponding field of the record accessed by the dataset.
Any Idea will be highly appreciated.
Dont know if this helps but you could do it a bit more manually like this , but it still uses the DataSet.
VB Code:
For intX = 0 To (intRecordCount - 1)
intAccountID = dsCustomers.Tables(0).Rows(intX).Item("pkAccountID")
strFamilyName = dsCustomers.Tables(0).Rows(intX).Item("fldFamilyName")
strFirstName = dsCustomers.Tables(0).Rows(intX).Item("fldFirstName")
strPCode = dsCustomers.Tables(0).Rows(intX).Item("fldPCode")
Next
-
Jul 5th, 2006, 10:08 AM
#7
Thread Starter
Addicted Member
Re: [2005] Read From A Dataset Instead Of DataReader
Thanks mikeLynch. i never knew it was that simple.
JMC...thanks too.
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
|