Sample ESQL/C program to connect to OneDB Server

Open “VS2017 Command Prompt” (or later version) window. You can use any text editor to use the below sample ESQL/C code, name it “esql_connect.ec “ and save the file. Run “esql esql-connect.ec” command, it will generate esql-connect.exe executable file. Run this executable file. You should get the SUCCESS message. Refer below image for more information.

#include <stdio.h>
#include <windows.h>
main()
{
printf("\n Sample ESQL Connect Program.\n");
EXEC SQL connect to 'sysmaster';
if (SQLCODE == 0)
printf(" Connected Successfully to 'sysmaster' database\n");
else
{
printf(" Connection error !!\n");
exit(-1);
}
EXEC SQL disconnect current;
printf(" Sample Program over.\n");
}