Visual C++ , from MySQL to TextBox.

EDN Admin

Well-known member
Joined
Aug 7, 2010
Messages
12,794
Location
In the Machine
hello folks,
I have developed a program that reads values from serial port and stores it in the MYSQL database. I want to retrieve all the values from the database to a textbox present in windows form application on click of button..
can any1 Help..?
thanks in advance.


this is the code : but it only gives me the 1st value from the SQL DB
private: System::Void button5_Click(System::Object^ sender, System::EventArgs^ e) <br/>
<span style="white-space:pre {<br/>
<span style="white-space:pre int query_state;<br/>
<span style="white-space:pre mysql_init(&mysql);<br/>
<span style="white-space:pre connection = mysql_real_connect(&mysql,"localhost","root","root","weight",0,0,0);<br/>
<span style="white-space:pre if(connection == NULL)<br/>
<span style="white-space:pre {<br/>
<span style="white-space:pre textBox3->Text="SQL Not Connected";<br/>
<span style="white-space:pre }<br/>
<span style="white-space:pre else <br/>
<span style="white-space:pre {<br/>
<span style="white-space:pre std::string DOIT= "select * from weht";<br/>
<span style="white-space:pre query_state = mysql_query(connection,DOIT.c_str());<br/>
<span style="white-space:pre if (query_state != 0)<br/>
<span style="white-space:pre {<br/>
<span style="white-space:pre <br/>
<span style="white-space:pre textBox3->Text="query error";<span style="white-space:pre
<br/>
<span style="white-space:pre }<br/>
<span style="white-space:pre else<br/>
<span style="white-space:pre {<br/>
<span style="white-space:pre result = mysql_store_result(connection);<br/>
<span style="white-space:pre <span style="white-space:pre <br/>
<span style="white-space:pre row = mysql_fetch_row(result);<br/>
<span style="white-space:pre std::ostringstream o;<br/>
<span style="white-space:pre o << row[0];<br/>
<span style="white-space:pre std::string s(o.str());<span style="white-space:pre
<br/>
<span style="white-space:pre textBox3->Text= gcnew System::String(s.c_str());<span style="white-space:pre
<br/>
<span style="white-space:pre }<br/>
<span style="white-space:pre <br/>
<span style="white-space:pre <br/>
<span style="white-space:pre }<br/>
<span style="white-space:pre <br/>
<span style="white-space:pre <br/>
<span style="white-space:pre }



View the full article
 
Back
Top