EDN Admin
Well-known member
Hi,
I have a sql table and I want to display the table values to a (multiline) textbox field in win form. presently mycode displays only first value present in the sql database.
Heres the code.
<span style="white-spacere //Show DB Button<br/>
private: System::Void button5_Click(System::Object^ sender, System::EventArgs^ e) <br/>
<span style="white-spacere {<br/>
<span style="white-spacere <span style="white-spacere int query_state;<br/>
<span style="white-spacere mysql_init(&mysql);<br/>
<span style="white-spacere connection = mysql_real_connect(&mysql,"localhost","root","root","weight",0,0,0);<br/>
<span style="white-spacere if(connection == NULL)<br/>
<span style="white-spacere {<br/>
<span style="white-spacere textBox3->Text="SQL Not Connected";<br/>
<span style="white-spacere }<br/>
<span style="white-spacere else <br/>
<span style="white-spacere {<br/>
<span style="white-spacere std::string DOIT= "select * from weht";<br/>
<span style="white-spacere query_state = mysql_query(connection,DOIT.c_str());<br/>
<span style="white-spacere if (query_state != 0)<br/>
<span style="white-spacere {<br/>
<span style="white-spacere <br/>
<span style="white-spacere textBox3->Text="query error";<span style="white-spacere
<br/>
<span style="white-spacere }<br/>
<span style="white-spacere else<br/>
<span style="white-spacere {<br/>
<span style="white-spacere this->textBox1->Text="query success";<br/>
<span style="white-spacere result = mysql_store_result(connection);<br/>
<span style="white-spacere //while ((row = mysql_fetch_row(result)) != NULL )<br/>
<span style="white-spacere {<span style="white-spacere <br/>
<span style="white-spacere row = mysql_fetch_row(result);<br/>
<span style="white-spacere std:stringstream o;<br/>
<span style="white-spacere o << row[0];<br/>
<span style="white-spacere std::string s(o.str());<span style="white-spacere
<br/>
<span style="white-spacere textBox3->Text= gcnew System::String(s.c_str());<span style="white-spacere
<br/>
<span style="white-spacere }<br/>
<span style="white-spacere <span style="white-spacere }<br/>
<span style="white-spacere <br/>
<span style="white-spacere }<br/>
<span style="white-spacere }
I thought the while loop will help me , but it didnt work. I have commented the while.
Please help me out.
thanks
View the full article
I have a sql table and I want to display the table values to a (multiline) textbox field in win form. presently mycode displays only first value present in the sql database.
Heres the code.
<span style="white-spacere //Show DB Button<br/>
private: System::Void button5_Click(System::Object^ sender, System::EventArgs^ e) <br/>
<span style="white-spacere {<br/>
<span style="white-spacere <span style="white-spacere int query_state;<br/>
<span style="white-spacere mysql_init(&mysql);<br/>
<span style="white-spacere connection = mysql_real_connect(&mysql,"localhost","root","root","weight",0,0,0);<br/>
<span style="white-spacere if(connection == NULL)<br/>
<span style="white-spacere {<br/>
<span style="white-spacere textBox3->Text="SQL Not Connected";<br/>
<span style="white-spacere }<br/>
<span style="white-spacere else <br/>
<span style="white-spacere {<br/>
<span style="white-spacere std::string DOIT= "select * from weht";<br/>
<span style="white-spacere query_state = mysql_query(connection,DOIT.c_str());<br/>
<span style="white-spacere if (query_state != 0)<br/>
<span style="white-spacere {<br/>
<span style="white-spacere <br/>
<span style="white-spacere textBox3->Text="query error";<span style="white-spacere
<br/>
<span style="white-spacere }<br/>
<span style="white-spacere else<br/>
<span style="white-spacere {<br/>
<span style="white-spacere this->textBox1->Text="query success";<br/>
<span style="white-spacere result = mysql_store_result(connection);<br/>
<span style="white-spacere //while ((row = mysql_fetch_row(result)) != NULL )<br/>
<span style="white-spacere {<span style="white-spacere <br/>
<span style="white-spacere row = mysql_fetch_row(result);<br/>
<span style="white-spacere std:stringstream o;<br/>
<span style="white-spacere o << row[0];<br/>
<span style="white-spacere std::string s(o.str());<span style="white-spacere
<br/>
<span style="white-spacere textBox3->Text= gcnew System::String(s.c_str());<span style="white-spacere
<br/>
<span style="white-spacere }<br/>
<span style="white-spacere <span style="white-spacere }<br/>
<span style="white-spacere <br/>
<span style="white-spacere }<br/>
<span style="white-spacere }
I thought the while loop will help me , but it didnt work. I have commented the while.
Please help me out.
thanks
View the full article