I am trying to insert a variable in a SQL string but am not having any success in finding the proper sytax. I am coding in C++. Listed below is code section I am trying to figure out. This code is part of an ADO routine that adds a field in an Access Database.
Code:
char Value[40];printf("Input A String");scanf("%s",Value);sSQLCommand = L"ALTER TABLE TableIn ADD @Value nvarchar(20)";com->CommandText = sSQLCommand;
Unfortunately what gets added to the database as a field is @Value.
After some corrections, the following is the corrected code that executes in sSQLCommand:
char sSQLCommand[100];
char TempField[50];
printf("Input Field");
scanf("%s",TempField);
sprintf_s(sSQLCommand,"ALTER TABLE TableIn ADD %s nvarchar(20)",TempField);