- In the extension bar, click the AdBlock Plus icon
- Click the large blue toggle for this website
- Click refresh
- In the extension bar, click the AdBlock icon
- Under "Pause on this site" click "Always"
- In the extension bar, click on the Adguard icon
- Click on the large green toggle for this website
- In the extension bar, click on the Ad Remover icon
- Click "Disable on This Website"
- In the extension bar, click on the orange lion icon
- Click the toggle on the top right, shifting from "Up" to "Down"
- In the extension bar, click on the Ghostery icon
- Click the "Anti-Tracking" shield so it says "Off"
- Click the "Ad-Blocking" stop sign so it says "Off"
- Refresh the page
- In the extension bar, click on the uBlock Origin icon
- Click on the big, blue power button
- Refresh the page
- In the extension bar, click on the uBlock icon
- Click on the big, blue power button
- Refresh the page
- In the extension bar, click on the UltraBlock icon
- Check the "Disable UltraBlock" checkbox
- Please disable your Ad Blocker
- Disable any DNS blocking tools such as AdGuardDNS or NextDNS
- Disable any privacy or tracking protection extensions such as Firefox Enhanced Tracking Protection or DuckDuckGo Privacy.
If the prompt is still appearing, please disable any tools or services you are using that block internet ads (e.g. DNS Servers, tracking protection or privacy extensions).
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