How to execute a query and check the results?

Discussion of open issues, suggestions and bugs regarding ADO.NET provider for MySQL
Post Reply
Posts: 1
Joined: Thu 26 Jan 2012 21:41

How to execute a query and check the results?

Post by tsvetanakos » Thu 26 Jan 2012 21:52

Hello! I'm really new in visual c++ and newer in dbforge.I have a question and hope that someone will answer it.I started a database application,but my problem is that I can't execute and see the query results.As I can see visual c++ have created 2 codes:

Code: Select all

// mySqlCommand1
			this->mySqlCommand1->CommandText = L"select *\r\nfrom Users";
			this->mySqlCommand1->Connection = this->mySqlConnection1;
			this->mySqlCommand1->Name = L"mySqlCommand1";
			this->mySqlCommand1->Owner = this;
			// mySqlConnection1
			this->mySqlConnection1->ConnectionString = L"User Id=programm;Host=*******.net;Database=programm;Password=14" 
			this->mySqlConnection1->Name = L"mySqlConnection1";
			this->mySqlConnection1->Owner = this;
Ok its very well made,but how can execute the mySqlCommand1 and see the results?
I have made a ritchtext box wich is supposed to show me the results:

Code: Select all

private: System::Void btntest_Click(System::Object^  sender, System::EventArgs^  e) {
				 box1-> Text = 
How am I supposed to print the results inthere?PLEASE help me!

any replay is highly appreciated!

THANKS in advance!

Devart Team
Posts: 2192
Joined: Wed 02 Nov 2011 09:44

Post by Pinturiccio » Fri 27 Jan 2012 14:02

When you want to retrieve all the data, returned by query "select * from", you should use a MySqlDataReader object. You can change your code to retrieve data from database:

Code: Select all

private: System::Void button1_Click(System::Object^  sender, System::EventArgs^  e) {
				 System::String^ str="";
				 Devart::Data::MySql::MySqlDataReader^ reader=MySqlCommand1->ExecuteReader();
				 while (reader->Read())
					for (int i=0;iFieldCount;i++)
For more details please refer to: ... eving.html
There are samples only for C# and Visual basic languages. So, if anything would be unclear, feel free to contact us.

Post Reply