if(rowsAffected >0) { MessageBox::Show("Registration Successful!"); login^ f5 =gcnew login(); f5->ShowDialog(); } else { MessageBox::Show("Registration Failed!"); Application::Exit(); }
and change it to ExecuteReader();
MySqlDataReader^ myReader; myReader=cmdDataBase->ExecuteReader();
the query goes through fine...
Not sure what i'm doing wrong, it seems fine...
how do i submit the insert query and check to see if it was successfully submitted?? ExecuteNonQuery(); doesn't work and not sure why???
private: System::Void registration_button_Click(System::Object^ sender, System::EventArgs^ e) { String^ constring=L"datasource=applicationdata.db.104xxxxx.hostedresource.com;port=3306;username=applicationdatas;password=xxxxxx"; MySqlConnection^ conDataBase=gcnew MySqlConnection(constring); MySqlCommand^ cmdDataBase=gcnew MySqlCommand("insert into applicationdatas.app_users (fname, email, password, address, country, state, city, postal_code, phone) VALUES ('"+this->ufullname_txt->Text+"', '"+this->uemail_txt->Text+"', '"+this->upassword_txt->Text+"', '"+this->uaddress_txt->Text+"', '"+this->country_comboBox->Text+"', '"+this->state_comboBox->Text+"', '"+this->city_comboBox->Text+"', '"+this->zipcode_txt->Text+"', '"+this->phone_txt->Text+"') ;",conDataBase); //MySqlDataReader^ myReader; try{ conDataBase->Open(); //myReader=cmdDataBase->ExecuteReader(); int rowsAffected = cmdDataBase->ExecuteNonQuery(); if(rowsAffected >0) { MessageBox::Show("Registration Successful!"); login^ f5 =gcnew login(); f5->ShowDialog(); } else { MessageBox::Show("Registration Failed!"); Application::Exit(); } conDataBase->Close(); }catch(Exception^ex){ MessageBox::Show(ex->Message); } }
From what i understand the ExecuteNonQuery(); should give affected rows but for some reason it's not working...