1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 | private : System::Void button1_Click(System::Object^ sender, System::EventArgs^ e) { String^connStr = "server=localhost;Database=test;Uid=root;Pwd=password" ; MySqlConnection^ conn = gcnew MySqlConnection(connStr); try { textBox1->AppendText( "Connecting to MySQL..." + "\r\n" ); conn->Open(); String^ sql = "SELECT name, age FROM `sampleTable`" ; MySqlCommand^ cmd = gcnew MySqlCommand(sql, conn); MySqlDataReader^ rdr = cmd->ExecuteReader(); while (rdr->Read()){ textBox1->AppendText(rdr[0] + " -- " + rdr[1] + "\r\n" ); } rdr->Close(); } catch (Exception^ e){ textBox1->AppendText(e->ToString()); } conn->Close(); textBox1->AppendText( "Done." + "\r\n" ); } |
2011年4月19日火曜日
データの表示(参照)
登録:
コメントの投稿 (Atom)
0 件のコメント:
コメントを投稿