MySql C++ Help

I created a registration form and when i test if my mysql insert query is successful nothing happens...

also notice the query isn't going through.
if i take out my if statements

1
2
3
4
5
6
7
8
9
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???


1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
private: System::Void registration_button_Click(System::Object^  sender, System::EventArgs^  e) 
{String^ constring=L"datasource=applicationdata.db.104xxxxx.hostedresou rce.com;port=3306;
username=applicationdata;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...
Last edited on
Topic archived. No new replies allowed.