0

Can anyone tell me (showing sample code) how to have embedded MS SQL Server SQL queries in a visual studio Win32 console application C++ program (header files, keywords, etc.)? I've set up a C++ project with source file and the standard EXEC SQL notation doesn't work. I did connect to the database through the server explorer window. So far, I've had no luck. I just want a little sample to show my class. Here's the basic code I've tried:

// DB TEST PROGRAM
#include <iostream>
using namespace std;

void main()
{
int customer;
double balance;

customer = 10013;

EXEC SQL SELECT CUS_BALANCE INTO :balance
         FROM CUSTOMER
         WHERE CUS_NUMBER = :Customer;

cout << "Customer " << customer << " has a balance of " << balance;
cin.ignore();  // to hold screen
}

0 Answers0