Version 1.3    10-11-2011 SoftNC ODBC SQL interface.

Function name:
SQL_Manage

Manage a named database through ODBC.


Input parm:
     diCommand : DINT; 
     sCommandData : STRING;
Output parm:
    sRespond : STRING;

Dependencies:
Requere ODBS 3.0 or higher.
SQL_Manage librarys define. (Download here)
SNSqlOdbc.dll for SoftNC. (Download here)
T5BLOCKS.dll version 2.3 or higher.

Status defines
Status return values.
#define SQL_STS_READY        1
#define SQL_STS_CONNECTING 2
#define SQL_STS_CONNECTED 3
#define SQL_STS_REQUESTOK 4
#define SQL_STS_REQUESTFAILED 5
#define SQL_STS_DATAFECHED 6
#define SQL_STS_DATAFECHFAILED 7

Command defines.
#define SN_SQL_CMD_CONNECT 1
#define SN_SQL_CMD_DISCON 2
#define SN_SQL_CMD_REQUIRE 3
#define SN_SQL_CMD_NEXT_ROW 4
#define SN_SQL_CMD_COULN 5
#define SN_SQL_CMD_STATUS 6
#define SN_SQL_CMD_SETTIMEOUT 7
#define SN_SQL_CMD_SET_OUTWIN 8
#define SN_SQL_CMD_DEL_OUTWIN 9
#define SN_SQL_CMD_KEEPALIVE    10
#define SN_SQL_CMD_WINWIDT 20
#define SN_SQL_CMD_WINHIG 21



Commands description
Define Value Description
SN_SQL_CMD_CONNECT 1 Command data contains DNS name and eg. user name and password for connecting to DNS name.
Status return:
SQL_STS_CONNECTING: While connecting
SQL_STS_CONNECTED when successful
SQL_STS_READY: when failed.
SN_SQL_CMD_DISCON 2 Abort any SQL activity.
Status return:
SQL_STS_READY: when interface is disconnected and ready for another connection..
SN_SQL_CMD_REQUIRE 3 Command data contains SQL request. This is sent to a connected database.
Status need to be SQL_STS_CONNECTED or higher for request to be passed to database.
Status return:
SQL_STS_REQUESTOK: request accepted by database.
SQL_STS_REQUESTFAILED:Request denied by database.
SN_SQL_CMD_NEXT_ROW 4 Fetches next row of data.
When request is passed to database this command need to be sent before any result can be feched from database.
This command takes no Command data.
Status return:
SQL_STS_DATAFECHED when all row are fetched. otherwise status is unchanged by this command.
SN_SQL_CMD_COULN 5 Get data from a coulmn specified by Command data.
Data is formatted in the format specified by table coulmn type.
Status return:
SQL_STS_DATAFECHFAILED: Fetch failed. Probably  due to not connected or wrong column.
SQL_STS_REQUESTOK: Fetch succeeded.
for version 1.4 or higher: if result is null, the respond is "<NULL>".
SN_SQL_CMD_STATUS 6 This command takes no Command data.
Status return:
all values defined SQL_STS_XXXXXXXX
SN_SQL_CMD_SETTIMEOUT 7 Set the time out in seconds specified in Command data.
The connection is automatically disconnected when the connection is idle for "Timeout" seconds.
This also the max time the ODBC interface is waiting for a web based database.
SN_SQL_CMD_SET_OUTWIN 8 Set a window that describes actions in the DLL.
This could be a god help to debugging
SN_SQL_CMD_DEL_OUTWIN 9 Close the window that show actions in the DLL
SN_SQL_CMD_KEEPALIVE 10 This command reset the timer that disconnect to the data base. If this is caaled with an interval  less then the timout value, the connection is manitained and never disconnected.
SN_SQL_CMD_WINWIDT 20 Set the width of the open output window in pixels. support from version 1.6. No retun value
SN_SQL_CMD_WINHIG 21 Set the Height of the open output window in pixels. support from version 1.6. No retun value



Straton Demo project: SqlDemo.zip (Download here)


Setting up ODBC:

Demo data base:

Download demo database here

Select appropriate driver.


Configure driver. Data source name is the name used to connect to the data base. (DNS name).