PC Review


Reply
Thread Tools Rate Thread

BindingSource based on object::typeid (how to fill data from DB)

 
 
pmz
Guest
Posts: n/a
 
      20th May 2011
Dear Friends,

1. I've created an object named i.e. Cup_Event with few properties
(getters & setters).
2. I've created DataGridView, with data source created from binding
source based on object mentioned above.

this->cupEventBindingSource->DataSource =
Cup:ata::Cup_Event::typeid;

The problem is, I'm not totally sure how do I fill my DGV with data?
I've done it before via BindingSource > DataSet < DbDataAdapter <
Fill, etc. and worked perfectly. Now I've tried something else, and
I'm stuck in the filling moment.

For sure I need to fetch data - the question is, shall I use
DataAdapter (MySqlDataAdapter/SqlDataAdapter) or DataReader and
building list of objects (Cup_Event)? Or maybe I use object for
building the DGV columns (VS designer) and further I may use the
DataSet-filling-method?

Thank you for any help,

Przemek M. Zawada
 
Reply With Quote
 
 
 
 
pmz
Guest
Posts: n/a
 
      20th May 2011
Okay, I've tried a bit risky, anyway with success:

this->cupEventBindingSource->DataSource =
Cup:ata::Cup_Event::typeid;
Cup:ata::Cup_Event^ cupEvent = gcnew Cup:ata::Cup_Event();
MySql:ata::MySqlClient::MySqlCommand^ cmd = gcnew
MySql:ata::MySqlClient::MySqlCommand("SELECT * FROM Cup_Event",
cupEvent->DatabaseConnection);
MySql:ata::MySqlClient::MySqlDataAdapter^ adapter = gcnew
MySql:ata::MySqlClient::MySqlDataAdapter(cmd);
DataSet^ ds = gcnew DataSet();
adapter->Fill(ds, "Cup_Event");
this->cupEventBindingSource->DataSource = ds->Tables["Cup_Event"];

Worked PERFECTLY, still, my question is - am I doing everything ok?

All the best,
Przemek M. Zawada
 
Reply With Quote
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Auto-Fill Column based on data in each row Dave Microsoft Excel Worksheet Functions 7 23rd May 2009 10:24 AM
Re: continuous - want to change properties of object based on another object data Allen Browne Microsoft Access Form Coding 0 18th Jun 2008 04:04 AM
Automatically fill in data based on data in another field in the table ChadK Microsoft Access Forms 1 15th Feb 2007 08:20 PM
Object reference not set to an instance of an object for data table fill Chuck Gantz Microsoft VB .NET 2 29th Oct 2005 08:10 PM
Re: Automatic Fill of Data Based on Another Cell Frank Kabel Microsoft Excel Worksheet Functions 0 9th Sep 2004 07:10 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 06:57 AM.