In this assignment, I am having to insert user information to tables that we have created and I am having this error that keeps on telling me

"
Code No: 80040e14
Code Message: IDispatch error #3092
Error Source: Microsoft OLE DB Provider for SQL Server
Error Description: The name 'Br' is not permitted in this context. Only constants, expressions, or variables
allowed here. Column names are not permitted
"

Br is just a test for the first name and it is supposed to be stored in a character array that inserted into our table for first_name which is a nvarchar(255)

I still have no idea what I am needing to do that will fix this error

Here is the code

void SetupAccount()
{
    int setupChoice;

    system("cls");
    cout << "Setup Accounts Menu\n";
    cout << "-------------------\n";
    cout << "1. Savings Account\n";
    cout << "2. Checking Account\n";
    cout << "3. Credit Cards\n";
    cout << "4. Loans\n";
    cout << "5. Exit\n\n";
    cout << "Please make a selection: ";

    cin >> setupChoice;

    cout << endl;

    switch (setupChoice)
    {
    case 1:
        int savID, savbalance;
        char savfname[50], savlname[50], savdate[50];

        try
        {
            hr2 = RecordSet.CreateInstance( __uuidof(ADODB::Recordset));

            cout << "Savings Account Set-Up\n";
            cout << "----------------------\n";
            cout << "Please enter first name: ";
            cin >> savfname;
            cout << "\nPlease enter last name: ";
            cin >> savlname;
            cout << "\nPlease enter an ID for the account number: ";
            cin >> savID;
            cout << "\nPlease enter the account balance: ";
            cin >> savbalance;
            cout << "\nPlease enter the account creation date (Ex. MM/DD/YYYY): ";
            cin >> savdate;


            sprintf(CmdStr, "insert into Savings (acct_number, first_name, last_name, acct_balance, acct_date) Values (%i, %s%, %s%, %i, %s%)", savID, savfname, savlname, savbalance, savdate);
            RecordSet->Open(CmdStr, DBConnect.GetInterfacePtr(), ADODB::adOpenDynamic, ADODB::adLockReadOnly, ADODB::adCmdText);
            cout<< "\n\nRecord Inserted.\n";
            system("pause");
            system("cls");

        }
        catch(_com_error &e)
        {
            ErrorHandler(e, ErrStr );
            printf(ErrStr);
            exit(0);
        }

        MainMenu();
        break;

    case 2:
        char checkfname[50], checklname[50], checkdate[50];
        int checkID, checkbalance;

        try
        {
            hr2 = RecordSet.CreateInstance( __uuidof(ADODB::Recordset));

            cout << "Checking Account Set-Up\n";
            cout << "-----------------------\n";
            cout << "Please enter first name: ";
            cin >> checkfname;
            cout << "\nPlease enter last name: ";
            cin >> checklname;
            cout << "\nPlease enter an ID for the account number: ";
            cin >> checkID;
            cout << "\nPlease enter the account balance: ";
            cin >> checkbalance;
            cout << "\nPlease enter the account creation date (Ex. MM/DD/YYYY): ";
            cin >> checkdate;


            sprintf(CmdStr, "insert into Checking (acct_number, first_name, last_name, acct_balance, acct_date) Values (%i, %s, %s, %i, %s)", checkID, checkfname, checklname, checkbalance, checkdate);
            RecordSet->Open(CmdStr, DBConnect.GetInterfacePtr(), ADODB::adOpenDynamic, ADODB::adLockReadOnly, ADODB::adCmdText);
            cout<< "\n\nRecord Inserted.\n";
            system("pause");
            system("cls");

        }
        catch(_com_error &e)
        {
            ErrorHandler(e, ErrStr );
            printf(ErrStr);
            exit(0);
        }

        MainMenu();
        break;

    case 3:
        char creditfname[50], creditlname[50], creditdate[50], creditcard[50];
        int creditID, creditbalance;

        try
        {
            hr2 = RecordSet.CreateInstance( __uuidof(ADODB::Recordset));

            cout << "Credit Card Account Set-Up\n";
            cout << "--------------------------\n";
            cout << "Please enter first name: ";
            cin >> creditfname;
            cout << "\nPlease enter last name: ";
            cin >> creditlname;
            cout << "\nPlease enter an ID for the account number: ";
            cin >> creditID;
            cout << "\nPlease enter the account balance: ";
            cin >> creditbalance;
            cout << "\nPlease enter the account creation date (Ex. MM/DD/YYYY): ";
            cin >> creditdate;
            cout << "\nPlease enter the credit card company that you signed with: ";
            cin >> creditcard;


            sprintf(CmdStr, "insert into Credit (card_type, acct_number, first_name, last_name, acct_balance, acct_date) Values (%i, %s, %s, %i, %s)", creditcard, creditID, creditfname, creditlname, creditbalance, creditdate);
            RecordSet->Open(CmdStr, DBConnect.GetInterfacePtr(), ADODB::adOpenDynamic, ADODB::adLockReadOnly, ADODB::adCmdText);
            cout<< "\n\nRecord Inserted.\n";
            system("pause");
            system("cls");

        }
        catch(_com_error &e)
        {
            ErrorHandler(e, ErrStr );
            printf(ErrStr);
            exit(0);
        }

        MainMenu();
        break;

    case 4:
        char loanfname[50], loanlname[50], loandate[50], loantype[50];
        int loanID, loanbalance;

        try
        {
            hr2 = RecordSet.CreateInstance( __uuidof(ADODB::Recordset));

            cout << "Loan Payment Account Set-Up\n";
            cout << "----------------------------\n";
            cout << "Please enter first name: ";
            cin >> loanfname;
            cout << "\nPlease enter last name: ";
            cin >> loanlname;
            cout << "\nPlease enter an ID for the account number: ";
            cin >> loanID;
            cout << "\nPlease enter the account balance: ";
            cin >> loanbalance;
            cout << "\nPlease enter the account creation date (Ex. MM/DD/YYYY): ";
            cin >> loandate;
            cout << "\nPlease enter the credit card company that you signed with: ";
            cin >> creditcard;


            sprintf(CmdStr, "insert into Loan (loan_type, acct_number, first_name, last_name, acct_balance, acct_date) Values (%i, %i, %s, %s, %i, %s)", loantype, loanID, loanfname, loanlname, loanbalance, loandate);
            RecordSet->Open(CmdStr, DBConnect.GetInterfacePtr(), ADODB::adOpenDynamic, ADODB::adLockReadOnly, ADODB::adCmdText);
            cout<< "\n\nRecord Inserted.\n";
            system("pause");
            system("cls");

        }
        catch(_com_error &e)
        {
            ErrorHandler(e, ErrStr );
            printf(ErrStr);
            exit(0);
        }

        MainMenu();
        break;
    }

}

Scratch, that. Forgot single quotes on the C placeholders.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.