C++ Showing Data Results MySQL

So right now i am currently trying to make a search function!
this is a picture of my current Application https://gyazo.com/38de0c30ba87e7c30fe6b7410a761c0d
As you can see i still haven't figured out requesting and displaying data info eg how many people are in the data base and what the current username is and a spew of other things i'd like to add in the future
::NOTE:: Forgot to add the "Search Button" i now notice lol
But what i am trying to do yet not really understanding how, i've seen some stuff kinda on how but i would like to know how it all really works instead of jst putting some code there and hoping it works but i am trying to make it so someone will enter a search term eg. John and press search, then in the results box it will list out all people in the database (MySQL) named John and their Last name and account number
1
2
3
4
5
6
7
//I've got down how i send a query to the DB but not how i'd recive output from it and display it on the application (The Search Function)
	private: System::Void button1_Click(System::Object^  sender, System::EventArgs^  e) {

		String^ constring = L"datasource=;port=3306;username=;password=";
		MySqlConnection^ conDatabase = gcnew MySqlConnection(constring);
		MySqlCommand^ cmdDatabase = gcnew MySqlCommand("select * from database.logins where user_name='"+this->textBox1->Text+"'and password='"+this->textBox2->Text+"';", conDatabase);
		MySqlDataReader^ myReader;


I as well am trying to make an admin page so if someone has an account of a certain level or what ever they can log into the Admin Page and from there add remove change etc from it as seen below i've got the C++ end of it down my main issue is just SQL as im not the freshest with SQL and then with the results and users in DB i am just clueless as to how i interpret the data
https://gyazo.com/486e346453a6ce2fa6044f305ba012ce
And how i would display things such as how many people are in the database etc

if ANYONE knows how i would go about these things and would tell me a great place for tutorials i would love to know!
Last edited on
I would recommend that you start very simple. For example try to display all data from a particular table in a ListBox. Then you can try with some more advanced queries.
@Thomas1965 Yea, that's what i am trying to do but i don't even know how to do something as "simple" as that i know how to query and such through c++ but i don't know how i'd take what i get from the database and put it in the list box
I've now figured out how to display data... or i thought, i watched something on getting data out and i can get integers out for example column 1 is ID i can get all those out but i want to extract registered user names which are the first column
my code
1
2
3
4
5
6
7
8
9
10
11
12
13
14
	String^ constring = L"datasource=;port=3306;username=;password=";
	MySqlConnection^ conDatabase = gcnew MySqlConnection(constring);
	MySqlCommand^ cmdDatabase = gcnew MySqlCommand("select * from logins.logins;", conDatabase);
	MySqlDataReader^ myReader;
	try {
		conDatabase->Open();
		myReader = cmdDatabase->ExecuteReader();
		while (myReader->Read()) {
			databox->Text += (myReader->GetString(1));
		}
	}
	catch (Exception^ex) {
		MessageBox::Show(ex->Message);
	};

what shows up in the box is one of the end passwords or something instead of the first login which is not what i want to show up
Last edited on
For example, if your table has a field called user_name you can access it with
 
myReader->GetString("user_name");
Last edited on
Topic archived. No new replies allowed.