This is a ONE-TO-N Relationship: Each Bailleur Has N fournisseur and each fournisseur has N bailleur
when i generated MPD I have a new table named fournir
IDF IDB
----+------
i want to insert data in "bailleur" by typing the name of founisseur which is namef and the IDF of "fournisseur" will be inserted into column IDF of table "bailleur" all this using c++
here is what ive tried i alredy inserted data in table "Fournisseur"
here im using bailleur in a class called bailleur
int qstate1;
MYSQL_ROW row1;
MYSQL_RES* res1;
void Bailleur::addb( MYSQL* conn){
string idf="";
cin.ignore(1, '\n');
cout << "Enter Nom du bailleur: ";
getline(cin, nomb);
cout << "Enter Adresse: ";
getline(cin, adresseb);
cout << "Enter tel : ";
getline(cin, telb);
cout<<"tapez le nom du fournisseur";
getline(cin,nomf);
string insert_query = ""insert into bailleur (IDF,nomb, tel_b ,adresseb)
values (select IDF from fournisseur where nomf = '"+nomfou+"'
,'"+nomb+"','"+telb+"','"+adresseb+"')";;
const char* q = insert_query.c_str();
qstate1 = mysql_query(conn, q);
if (!qstate1)
{
cout << endl << "Successfully added in database." << endl;
}
LP cores are MUCH lower power than Efficiency cores. Efficiency cores never really lived up to their name, but they did add a meaningful amount of performance in multithreaded loads, so Intel isn't going to remove them.
I don't usually say this, but WTF Microsoft?! Do you hate your customers, or do you just really not care at all? Windows Hello is one of the useful Windows features, and now you're effing it up.
Question
niniben
I have a Table Bailleur
IDB IDF nameb Adresseb telb
----+------+------+---------------+-------
Where IDF is a foreign key to a table named Fournisseur
The Addresses Table:
IDF namef adressef telf
----+-------+----------+------+
This is a ONE-TO-N Relationship: Each Bailleur Has N fournisseur and each fournisseur has N bailleur
when i generated MPD I have a new table named fournir
IDF IDB
----+------
i want to insert data in "bailleur" by typing the name of founisseur which is namef and the IDF of "fournisseur" will be inserted into column IDF of table "bailleur" all this using c++
here is what ive tried i alredy inserted data in table "Fournisseur"
here im using bailleur in a class called bailleur
int qstate1;
MYSQL_ROW row1;
MYSQL_RES* res1;
void Bailleur::addb( MYSQL* conn){
string idf="";
cin.ignore(1, '\n');
cout << "Enter Nom du bailleur: ";
getline(cin, nomb);
cout << "Enter Adresse: ";
getline(cin, adresseb);
cout << "Enter tel : ";
getline(cin, telb);
cout<<"tapez le nom du fournisseur";
getline(cin,nomf);
string insert_query = ""insert into bailleur (IDF,nomb, tel_b ,adresseb)
values (select IDF from fournisseur where nomf = '"+nomfou+"'
,'"+nomb+"','"+telb+"','"+adresseb+"')";;
const char* q = insert_query.c_str();
qstate1 = mysql_query(conn, q);
if (!qstate1)
{
cout << endl << "Successfully added in database." << endl;
}
else
{
cout << "Query Execution Problem!" << mysql_errno(conn) << endl;
}
}
i expect output to be successfully added in database but its alway query execution problem
sorry for the long post this is my first time posting in neowin
Link to comment
https://www.neowin.net/forum/topic/1385153-how-to-insert-data-in-a-table-that-has-a-foreign-key-of-another-table-using-c-code/Share on other sites
0 answers to this question
Recommended Posts