Answered step by step
Verified Expert Solution
Question
1 Approved Answer
I ' m using the sakila database. I need help with my viewCustomer function ( listed below ) . Here is a description for what
Im using the sakila database. I need help with my viewCustomer function listed below Here is a description for what it needs to do: This function should run a query that gets the customer information for all customers in the database and uses that to display a menu of options containing the id last name, first name to the user. Based on the user choice the function should print the customer's name, phone number, and address including city, email address, if they are active, and last update for the record. You should use prepared statements to run the queries. Here is the code: "void viewCustomersqlite db
string query "SELECT customerid lastname, firstname FROM customer";
sqlitestmt stmt;
int rc sqlitepreparevdb query.cstr &stmt NULL;
if rc SQLITEOK
cerr "Error preparing statement: sqliteerrmsgdb endl;
sqliteclosedb;
exit;
cout "Please choose the customer you want to see:" endl;
int pageNum ;
int rowsPerPage ;
int choice;
while true
Execute the prepared statement
for int i ; i rowsPerPage; i
if sqlitestepstmt SQLITEROW
cout pageNum rowsPerPage i ;
cout sqlitecolumnintstmt;
cout sqlitecolumntextstmt;
cout sqlitecolumntextstmt endl;
else
No more rows
break;
cout "Please choose the customer you want to see enter to go to the next page";
cout or to go to the previous page: ;
cin choice;
if choice
pageNum;
else if choice
pageNum max pageNum ;
else
Invalid choice
cout "Invalid choice. Please try again." endl;
sqlitefinalizestmt;
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started