Last post Aug 21, 2019 07:04 PM by PatriceSc
Aug 21, 2019 01:47 AM|aakashbashyal|LINK
I am trying to create the embedded SQL program in C, using the visual studio 2017.
I have just started to write the initial code as below:
I am following the code from the Microsoft documentation of embedded sql
EXEC SQL INCLUDE SQLCA;
But got the error identifier "EXEC" is undefined:
identifier "EXEC" is undefined
I am using the version 15.9.3 of visual studio. For creating the c project i choose file>new>new project>visual c++>windows desktop wizard
file>new>new project>visual c++>windows desktop wizard
Application type as: Console application, and chose the Precompiled header.
May be i am missing any header or library to include on the program?
Aug 21, 2019 03:55 PM|bruce (sqlwork.com)|LINK
you need to run the source code thru the sql precompiler before the c/c++ compiler. which sql precompiler are you using? each database provider supplies the precompiker for their database, and should have instructions for using.
here are the instructions for using the Oracle sql precompiler with visual studio :
the Oracle precompiler generates CLI instead of odbc, so only works with Oracle databases.
Microsoft stopped embedded sql support with sqlserver 2008 (which itself is no longer supported). the compiler should have been a tool in the client tools/sdk.
note: back when I used C/C++ and sqlserver, I used dblib which was written to be used from C/C++. but its no longer supported either. I also used ODBC which is pretty easy from C/C++ . if you are using SQLServer then you want to use ODBC:
Aug 21, 2019 04:00 PM|aakashbashyal|LINK
i am using the default compiler provided by the Visual studio 2017. Currently i have no idea which SQL precompiler i am using or trying to use.
However i need to connect to SQL server database version of 2017.
Isn't there way without the ODBC to use with the SQL server database from visual studio? I have also tried to use the ODBC but that seems to much setup for the purpose i am trying to use.
My requirement to implement the embedded sql with the sql server database.
error window: https://drive.google.com/open?id=1D1YNKT7QusJSSIrNXKl6oQUjnuWFgcHf
Aug 21, 2019 04:07 PM|bruce (sqlwork.com)|LINK
If you are using SQLServer 2017 and C/C++ then your only options are ODBC and OLEDB. ODBC is much easier to use from C/C++.
note: I believe the sql precompiler for SQLServer was the Sybase one that generated dblib code. As dblib was not maintained for newer versions of SQLServer, the precompiler no longer works.
Aug 21, 2019 04:13 PM|aakashbashyal|LINK
Can you point me to the tutorial or proper documentation for using ODBC. As the documentation in Microsoft site is so vague that i am struck to initial start.
Aug 21, 2019 05:12 PM|bruce (sqlwork.com)|LINK
all I have ever used is the api documentation:
this is an old library, so I'm sure you can find books or articles if you google. the first google hit looks ok:
this site is handy to build a connection string:
Aug 21, 2019 07:04 PM|PatriceSc|LINK
And finally if you need further help it could be better to post to some forum at https://social.msdn.microsoft.com/Forums/en-us/home?filter=alltypes&sort=relevancedesc&brandIgnore=True&filter=alltypes&searchTerm=embedded+sql rather
than in an ASP.NET forum (which uses C# or maybe VB.NET).