List:Commits« Previous MessageNext Message »
From:pharvey Date:December 8 2006 12:47am
Subject:Connector/ODBC 5 commit: r713 - in trunk/Driver/examples: . c c/tutorial
View as plain text  
Added:
   trunk/Driver/examples/c/tutorial/
   trunk/Driver/examples/c/tutorial/README.txt
   trunk/Driver/examples/c/tutorial/examples-c.vpj
   trunk/Driver/examples/c/tutorial/tutorial_01.c
   trunk/Driver/examples/c/tutorial/tutorial_02.c
   trunk/Driver/examples/c/tutorial/tutorial_03.c
   trunk/Driver/examples/c/tutorial/tutorial_04.c
   trunk/Driver/examples/c/tutorial/tutorial_05.c
   trunk/Driver/examples/c/tutorial/tutorial_06.c
   trunk/Driver/examples/c/tutorial/tutorial_07.c
   trunk/Driver/examples/c/tutorial/tutorial_08.c
   trunk/Driver/examples/c/tutorial/tutorial_09.c
   trunk/Driver/examples/c/tutorial/tutorial_10.c
   trunk/Driver/examples/vb7/
   trunk/Driver/examples/vc7/
Removed:
   trunk/Driver/examples/c/README.txt
   trunk/Driver/examples/c/examples-c.vpj
   trunk/Driver/examples/c/tutorial_01.c
   trunk/Driver/examples/c/tutorial_02.c
   trunk/Driver/examples/c/tutorial_03.c
   trunk/Driver/examples/c/tutorial_04.c
   trunk/Driver/examples/c/tutorial_05.c
   trunk/Driver/examples/c/tutorial_06.c
   trunk/Driver/examples/c/tutorial_07.c
   trunk/Driver/examples/c/tutorial_08.c
   trunk/Driver/examples/c/tutorial_09.c
   trunk/Driver/examples/c/tutorial_10.c
   trunk/Driver/examples/vb/
Log:
a little reorg of driver examples

Deleted: trunk/Driver/examples/c/README.txt
===================================================================
--- trunk/Driver/examples/c/README.txt	2006-12-08 00:37:24 UTC (rev 712)
+++ trunk/Driver/examples/c/README.txt	2006-12-08 00:47:20 UTC (rev 713)
@@ -1,52 +0,0 @@
-DRIVER EXAMPLES
-C Language
----------------
-
-These examples are used for;
-
-	1. tutorial
-	2. doxygen based source code documentation (for examples)
-	3. stand-alone examples
-
-The source files should be numbered in ascending order of difficulty
-in accordance with what the tutorial needs.
-
-The source files must NOT be nested in sub directories as doxygen
-does not support this.
-
-Tutorial
---------
-
-The following files are used for a Tutorial. Some of these are also
-used for doxygen based code documentation.
-
-tutorial_01.c Allocate an environment handle, set desired ODBC version.
-tutorial_02.c Allocate a connection handle.
-tutorial_03.c Connect to a data source.
-tutorial_04.c Get diagnostic information.
-tutorial_05.c Allocate a statement.
-tutorial_06.c Submit a command to the data source.
-tutorial_07.c Get number of columns in result-set.
-tutorial_08.c Get number of affected rows.
-tutorial_09.c Get number of rows in result-set.
-tutorial_10.c Get result-set data.
-
-Examples
---------
-
-The following files compliment the Tutorial files.
-
-example_01.c Connect using SQLBrowseConnect.
-example_02.c Connection using SQLDriverConnect.
-example_04.c Get information about driver and data source. 
-example_05.c Get information about data types supported.
-example_06.c Discover tables.
-example_07.c Discover table columns.
-example_08.c Discover table keys.
-example_09.c Discover table indexs.
-example_10.c Discover procedures.
-example_11.c Discover procedures columns.
-
---
-Peter Harvey pharvey@stripped
- 

Deleted: trunk/Driver/examples/c/examples-c.vpj
===================================================================
--- trunk/Driver/examples/c/examples-c.vpj	2006-12-08 00:37:24 UTC (rev 712)
+++ trunk/Driver/examples/c/examples-c.vpj	2006-12-08 00:47:20 UTC (rev 713)
@@ -1,81 +0,0 @@
-<!DOCTYPE Project SYSTEM "http://www.slickedit.com/dtd/vse/10.0/vpj.dtd">
-<Project
-	Version="10.0"
-	VendorName="SlickEdit"
-	WorkingDir=".">
-	<Config
-		Name="Release"
-		OutputFile=""
-		CompilerConfigName="Latest Version">
-		<Menu>
-			<Target
-				Name="Compile"
-				MenuCaption="&amp;Compile"
-				CaptureOutputWith="ProcessBuffer"
-				SaveOption="SaveCurrent"
-				RunFromDir="%rw">
-				<Exec/>
-			</Target>
-			<Target
-				Name="Build"
-				MenuCaption="&amp;Build"
-				CaptureOutputWith="ProcessBuffer"
-				SaveOption="SaveWorkspaceFiles"
-				RunFromDir="%rw">
-				<Exec/>
-			</Target>
-			<Target
-				Name="Rebuild"
-				MenuCaption="&amp;Rebuild"
-				CaptureOutputWith="ProcessBuffer"
-				SaveOption="SaveWorkspaceFiles"
-				RunFromDir="%rw">
-				<Exec/>
-			</Target>
-			<Target
-				Name="Debug"
-				MenuCaption="&amp;Debug"
-				SaveOption="SaveNone"
-				RunFromDir="%rw">
-				<Exec/>
-			</Target>
-			<Target
-				Name="Execute"
-				MenuCaption="E&amp;xecute"
-				SaveOption="SaveNone"
-				RunFromDir="%rw">
-				<Exec CmdLine='"examples-c.exe"'/>
-			</Target>
-		</Menu>
-	</Config>
-	<Files>
-		<Folder
-			Name="Source Files"
-			Filters="*.c;*.C;*.cc;*.cpp;*.cp;*.cxx;*.prg;*.pas;*.dpr;*.asm;*.s;*.bas;*.java;*.cs;*.sc;*.e;*.cob;*.html;*.rc;*.tcl;*.py;*.pl">
-			<F N="tutorial_01.c"/>
-			<F N="tutorial_02.c"/>
-			<F N="tutorial_03.c"/>
-			<F N="tutorial_04.c"/>
-			<F N="tutorial_05.c"/>
-			<F N="tutorial_06.c"/>
-			<F N="tutorial_07.c"/>
-			<F N="tutorial_08.c"/>
-			<F N="tutorial_09.c"/>
-			<F N="tutorial_10.c"/>
-		</Folder>
-		<Folder
-			Name="Header Files"
-			Filters="*.h;*.H;*.hh;*.hpp;*.hxx;*.inc;*.sh;*.cpy;*.if"/>
-		<Folder
-			Name="Resource Files"
-			Filters="*.ico;*.cur;*.dlg"/>
-		<Folder
-			Name="Bitmaps"
-			Filters="*.bmp"/>
-		<Folder
-			Name="Other Files"
-			Filters="">
-			<F N="README.txt"/>
-		</Folder>
-	</Files>
-</Project>

Added: trunk/Driver/examples/c/tutorial/README.txt
===================================================================
--- trunk/Driver/examples/c/tutorial/README.txt	2006-12-08 00:37:24 UTC (rev 712)
+++ trunk/Driver/examples/c/tutorial/README.txt	2006-12-08 00:47:20 UTC (rev 713)
@@ -0,0 +1,52 @@
+DRIVER EXAMPLES
+C Language
+---------------
+
+These examples are used for;
+
+	1. tutorial
+	2. doxygen based source code documentation (for examples)
+	3. stand-alone examples
+
+The source files should be numbered in ascending order of difficulty
+in accordance with what the tutorial needs.
+
+The source files must NOT be nested in sub directories as doxygen
+does not support this.
+
+Tutorial
+--------
+
+The following files are used for a Tutorial. Some of these are also
+used for doxygen based code documentation.
+
+tutorial_01.c Allocate an environment handle, set desired ODBC version.
+tutorial_02.c Allocate a connection handle.
+tutorial_03.c Connect to a data source.
+tutorial_04.c Get diagnostic information.
+tutorial_05.c Allocate a statement.
+tutorial_06.c Submit a command to the data source.
+tutorial_07.c Get number of columns in result-set.
+tutorial_08.c Get number of affected rows.
+tutorial_09.c Get number of rows in result-set.
+tutorial_10.c Get result-set data.
+
+Examples
+--------
+
+The following files compliment the Tutorial files.
+
+example_01.c Connect using SQLBrowseConnect.
+example_02.c Connection using SQLDriverConnect.
+example_04.c Get information about driver and data source. 
+example_05.c Get information about data types supported.
+example_06.c Discover tables.
+example_07.c Discover table columns.
+example_08.c Discover table keys.
+example_09.c Discover table indexs.
+example_10.c Discover procedures.
+example_11.c Discover procedures columns.
+
+--
+Peter Harvey pharvey@stripped
+ 

Added: trunk/Driver/examples/c/tutorial/examples-c.vpj
===================================================================
--- trunk/Driver/examples/c/tutorial/examples-c.vpj	2006-12-08 00:37:24 UTC (rev 712)
+++ trunk/Driver/examples/c/tutorial/examples-c.vpj	2006-12-08 00:47:20 UTC (rev 713)
@@ -0,0 +1,81 @@
+<!DOCTYPE Project SYSTEM "http://www.slickedit.com/dtd/vse/10.0/vpj.dtd">
+<Project
+	Version="10.0"
+	VendorName="SlickEdit"
+	WorkingDir=".">
+	<Config
+		Name="Release"
+		OutputFile=""
+		CompilerConfigName="Latest Version">
+		<Menu>
+			<Target
+				Name="Compile"
+				MenuCaption="&amp;Compile"
+				CaptureOutputWith="ProcessBuffer"
+				SaveOption="SaveCurrent"
+				RunFromDir="%rw">
+				<Exec/>
+			</Target>
+			<Target
+				Name="Build"
+				MenuCaption="&amp;Build"
+				CaptureOutputWith="ProcessBuffer"
+				SaveOption="SaveWorkspaceFiles"
+				RunFromDir="%rw">
+				<Exec/>
+			</Target>
+			<Target
+				Name="Rebuild"
+				MenuCaption="&amp;Rebuild"
+				CaptureOutputWith="ProcessBuffer"
+				SaveOption="SaveWorkspaceFiles"
+				RunFromDir="%rw">
+				<Exec/>
+			</Target>
+			<Target
+				Name="Debug"
+				MenuCaption="&amp;Debug"
+				SaveOption="SaveNone"
+				RunFromDir="%rw">
+				<Exec/>
+			</Target>
+			<Target
+				Name="Execute"
+				MenuCaption="E&amp;xecute"
+				SaveOption="SaveNone"
+				RunFromDir="%rw">
+				<Exec CmdLine='"examples-c.exe"'/>
+			</Target>
+		</Menu>
+	</Config>
+	<Files>
+		<Folder
+			Name="Source Files"
+			Filters="*.c;*.C;*.cc;*.cpp;*.cp;*.cxx;*.prg;*.pas;*.dpr;*.asm;*.s;*.bas;*.java;*.cs;*.sc;*.e;*.cob;*.html;*.rc;*.tcl;*.py;*.pl">
+			<F N="tutorial_01.c"/>
+			<F N="tutorial_02.c"/>
+			<F N="tutorial_03.c"/>
+			<F N="tutorial_04.c"/>
+			<F N="tutorial_05.c"/>
+			<F N="tutorial_06.c"/>
+			<F N="tutorial_07.c"/>
+			<F N="tutorial_08.c"/>
+			<F N="tutorial_09.c"/>
+			<F N="tutorial_10.c"/>
+		</Folder>
+		<Folder
+			Name="Header Files"
+			Filters="*.h;*.H;*.hh;*.hpp;*.hxx;*.inc;*.sh;*.cpy;*.if"/>
+		<Folder
+			Name="Resource Files"
+			Filters="*.ico;*.cur;*.dlg"/>
+		<Folder
+			Name="Bitmaps"
+			Filters="*.bmp"/>
+		<Folder
+			Name="Other Files"
+			Filters="">
+			<F N="README.txt"/>
+		</Folder>
+	</Files>
+</Project>

Added: trunk/Driver/examples/c/tutorial/tutorial_01.c
===================================================================
--- trunk/Driver/examples/c/tutorial/tutorial_01.c	2006-12-08 00:37:24 UTC (rev 712)
+++ trunk/Driver/examples/c/tutorial/tutorial_01.c	2006-12-08 00:47:20 UTC (rev 713)
@@ -0,0 +1,31 @@
+/*
+    Tutorial step 01.
+
+    In this step we provide an example of how to allocate an environment handle.
+*/
+#include <sql.h>
+#include <sqlext.h>
+
+int main( int argc, char *argv[] )
+{
+    SQLHENV     hEnv;
+    SQLRETURN   nReturn;
+
+    /* Allocate the environment handle. */
+    nReturn = SQLAllocHandle( SQL_HANDLE_ENV, NULL, &hEnv );
+    /* 
+        Tell the Driver Manager and/or Driver that we are expecting ODBC v3 behaviour. 
+        The default is ODBC v2 behaviour.
+        All new applications should set this to ODBC v3. 
+        This should be done before any connections are allocated.
+    */
+    nReturn = SQLSetEnvAttr( hEnv, SQL_ATTR_ODBC_VERSION, SQL_OV_ODBC3, 0 );
+
+    /* We normally do stuff here but lets just exit. */
+
+    /* Free resources used by the handle. */
+    nReturn = SQLFreeHandle( SQL_HANDLE_ENV, hEnv );
+
+    return( 0 );
+}
+

Added: trunk/Driver/examples/c/tutorial/tutorial_02.c
===================================================================
--- trunk/Driver/examples/c/tutorial/tutorial_02.c	2006-12-08 00:37:24 UTC (rev 712)
+++ trunk/Driver/examples/c/tutorial/tutorial_02.c	2006-12-08 00:47:20 UTC (rev 713)
@@ -0,0 +1,34 @@
+/*
+    Tutorial step 02.
+
+    In this step we provide an example of how to allocate a connection handle.
+*/
+#include <sql.h>
+#include <sqlext.h>
+
+int main( int argc, char *argv[] )
+{
+    SQLHENV     hEnv;
+    SQLHDBC     hDbc;
+    SQLRETURN   nReturn;
+    
+    /* init */
+    nReturn = SQLAllocHandle( SQL_HANDLE_ENV, NULL, &hEnv );
+    nReturn = SQLSetEnvAttr( hEnv, SQL_ATTR_ODBC_VERSION, SQL_OV_ODBC3, 0 );
+
+    /* 
+        Allocate a connection handle. A single environment may have 0 or more
connections.
+    */
+    nReturn = SQLAllocHandle( SQL_HANDLE_DBC, hEnv, &hDbc );
+
+    /* We normally do stuff here but lets just exit. */
+
+    /* Free resources used by the handle. */
+    nReturn = SQLFreeHandle( SQL_HANDLE_DBC, hDbc );
+
+    /* fini */
+    nReturn = SQLFreeHandle( SQL_HANDLE_ENV, hEnv );
+
+    return( 0 );
+}
+

Added: trunk/Driver/examples/c/tutorial/tutorial_03.c
===================================================================
--- trunk/Driver/examples/c/tutorial/tutorial_03.c	2006-12-08 00:37:24 UTC (rev 712)
+++ trunk/Driver/examples/c/tutorial/tutorial_03.c	2006-12-08 00:47:20 UTC (rev 713)
@@ -0,0 +1,37 @@
+/*
+    Tutorial step 03.
+
+    In this step we provide an example of how to connect to a data source.
+*/
+#include <sql.h>
+#include <sqlext.h>
+
+int main( int argc, char *argv[] )
+{
+    SQLHENV     hEnv;
+    SQLHDBC     hDbc;
+    SQLRETURN   nReturn;
+    SQLCHAR *   pszDSN  = argv[1]; /* An existing DSN usually created by "ODBCConfig" or
"ODBC Administrator". */
+    SQLCHAR *   pszUID  = argv[2];
+    SQLCHAR *   pszPWD  = argv[3];
+
+    /* init */
+    nReturn = SQLAllocHandle( SQL_HANDLE_ENV, NULL, &hEnv );
+    nReturn = SQLSetEnvAttr( hEnv, SQL_ATTR_ODBC_VERSION, SQL_OV_ODBC3, 0 );
+    nReturn = SQLAllocHandle( SQL_HANDLE_DBC, hEnv, &hDbc );
+
+    /* Connect using an existing DSN. */
+    nReturn = SQLConnect( hDbc, pszDSN, SQL_NTS, pszUID, SQL_NTS, pszPWD, SQL_NTS );
+
+    /* We normally do stuff here but lets just exit. */
+
+    /* Disconnect. */
+    nReturn = SQLDisconnect( hDbc );
+
+    /* fini */
+    nReturn = SQLFreeHandle( SQL_HANDLE_DBC, hDbc );
+    nReturn = SQLFreeHandle( SQL_HANDLE_ENV, hEnv );
+
+    return( 0 );
+}
+

Added: trunk/Driver/examples/c/tutorial/tutorial_04.c
===================================================================
--- trunk/Driver/examples/c/tutorial/tutorial_04.c	2006-12-08 00:37:24 UTC (rev 712)
+++ trunk/Driver/examples/c/tutorial/tutorial_04.c	2006-12-08 00:47:20 UTC (rev 713)
@@ -0,0 +1,79 @@
+/*
+    Tutorial step 04.
+
+    In this step we provide an example of how to get diagnostic information.
+*/
+#include <sql.h>
+#include <sqlext.h>
+
+void dumpDiagnostics( SQLSMALLINT nHandleType, SQLHANDLE hHandle )
+{
+    SQLSMALLINT nRecord = 1;
+    SQLWCHAR    sState[6];
+    SQLINTEGER  nNativeError;
+    SQLWCHAR    sMessageText[SQL_MAX_MESSAGE_LENGTH];
+    SQLSMALLINT nTextLength;
+
+    /*
+        The oldest diagnostic record will be 1. The driver is only obligated to
+        return up to 8 records but most will return more (as needed). 
+
+        We loop through all records - printing them to stdout.
+
+        We use the SQL_SUCCEED macro to tell us if we have a SQL_SUCCESS
+        or SQL_SUCCESS_WITH_INFO. We expect to break out of loop when
+        SQLGetDiagRec returns SQL_NO_DATA.
+    */
+    while ( SQL_SUCCEEDED( SQLGetDiagRec( nHandleType, 
+                                          hHandle, 
+                                          nRecord, 
+                                          sState,
+                                          &nNativeError,
+                                          sMessageText,
+                                          SQL_MAX_MESSAGE_LENGTH,
+                                          &nTextLength )) )
+    {
+        sState[5] = '\0';
+        printf( "[%s][%d] %s\n", sState, nNativeError, sMessageText );
+        nRecord++;
+    }
+}
+
+int main( int argc, char *argv[] )
+{
+    SQLHENV     hEnv;
+    SQLHDBC     hDbc;
+    SQLRETURN   nReturn;
+    SQLCHAR *   pszDSN  = argv[1]; /* An existing DSN usually created by "ODBCConfig" or
"ODBC Administrator". */
+    SQLCHAR *   pszUID  = argv[2];
+    SQLCHAR *   pszPWD  = argv[3];
+
+    /* init */
+    nReturn = SQLAllocHandle( SQL_HANDLE_ENV, NULL, &hEnv );
+    nReturn = SQLSetEnvAttr( hEnv, SQL_ATTR_ODBC_VERSION, SQL_OV_ODBC3, 0 );
+    nReturn = SQLAllocHandle( SQL_HANDLE_DBC, hEnv, &hDbc );
+    nReturn = SQLConnect( hDbc, pszDSN, SQL_NTS, pszUID, SQL_NTS, pszPWD, SQL_NTS );
+
+    /* Check return code to see how things went for the last ODBC call. */
+    switch ( nReturn )
+    {
+        case SQL_ERROR:
+            dumpDiagnostics( SQL_HANDLE_DBC, hDbc );
+            goto exit1;
+        case SQL_SUCCESS_WITH_INFO:
+            dumpDiagnostics( SQL_HANDLE_DBC, hDbc );
+            break;
+    }
+
+    /* We normally do stuff here but lets just exit. */
+
+    nReturn = SQLDisconnect( hDbc );
+
+exit1:
+    /* fini */
+    nReturn = SQLFreeHandle( SQL_HANDLE_DBC, hDbc );
+    nReturn = SQLFreeHandle( SQL_HANDLE_ENV, hEnv );
+
+    return( 0 );
+}
+

Added: trunk/Driver/examples/c/tutorial/tutorial_05.c
===================================================================
--- trunk/Driver/examples/c/tutorial/tutorial_05.c	2006-12-08 00:37:24 UTC (rev 712)
+++ trunk/Driver/examples/c/tutorial/tutorial_05.c	2006-12-08 00:47:20 UTC (rev 713)
@@ -0,0 +1,42 @@
+/*
+    Tutorial step 05.
+
+    In this step we provide an example of how to allocate a statement handle.
+*/
+#include <sql.h>
+#include <sqlext.h>
+
+int main( int argc, char *argv[] )
+{
+    SQLHENV     hEnv;
+    SQLHDBC     hDbc;
+    SQLHSTMT    hStm;
+    SQLRETURN   nReturn;
+    SQLCHAR *   pszDSN  = argv[1];
+    SQLCHAR *   pszUID  = argv[2];
+    SQLCHAR *   pszPWD  = argv[3];
+
+    /* init */
+    nReturn = SQLAllocHandle( SQL_HANDLE_ENV, NULL, &hEnv );
+    nReturn = SQLSetEnvAttr( hEnv, SQL_ATTR_ODBC_VERSION, SQL_OV_ODBC3, 0 );
+    nReturn = SQLAllocHandle( SQL_HANDLE_DBC, hEnv, &hDbc );
+    nReturn = SQLConnect( hDbc, pszDSN, SQL_NTS, pszUID, SQL_NTS, pszPWD, SQL_NTS );
+
+    /* 
+        Allocate a statement handle. A single connection may have 0 or more statements.
+    */
+    nReturn = SQLAllocHandle( SQL_HANDLE_STMT, hDbc, hStmt );
+
+    /* We normally do stuff here but lets just exit. */
+
+    /* Free resources used by the handle. */
+    nReturn = SQLFreeHandle( SQL_HANDLE_STMT, hStm );
+
+    /* fini */
+    nReturn = SQLDisconnect( hDbc );
+    nReturn = SQLFreeHandle( SQL_HANDLE_DBC, hDbc );
+    nReturn = SQLFreeHandle( SQL_HANDLE_ENV, hEnv );
+
+    return( 0 );
+}
+

Added: trunk/Driver/examples/c/tutorial/tutorial_06.c
===================================================================
--- trunk/Driver/examples/c/tutorial/tutorial_06.c	2006-12-08 00:37:24 UTC (rev 712)
+++ trunk/Driver/examples/c/tutorial/tutorial_06.c	2006-12-08 00:47:20 UTC (rev 713)
@@ -0,0 +1,41 @@
+/*
+    Tutorial step 06.
+
+    In this step we provide an example of how to submit a command to the data source.
+*/
+#include <sql.h>
+#include <sqlext.h>
+
+int main( int argc, char *argv[] )
+{
+    SQLHENV     hEnv;
+    SQLHDBC     hDbc;
+    SQLHSTMT    hStm;
+    SQLRETURN   nReturn;
+    SQLCHAR *   pszDSN     = argv[1];
+    SQLCHAR *   pszUID     = argv[2];
+    SQLCHAR *   pszPWD     = argv[3];
+    SQLCHAR *   pszCommand = "CREATE TABLE Tutorial AS " /
+                             "(                        " /
+                             "   nID    NUMERIC(6),    " /
+                             "   vcData VARCHAR(50)    " /
+                             ")                        ";
+
+    /* init */
+    nReturn = SQLSetEnvAttr( hEnv, SQL_ATTR_ODBC_VERSION, SQL_OV_ODBC3, 0 );
+    nReturn = SQLAllocHandle( SQL_HANDLE_DBC, hEnv, &hDbc );
+    nReturn = SQLConnect( hDbc, pszDSN, SQL_NTS, pszUID, SQL_NTS, pszPWD, SQL_NTS );
+    nReturn = SQLAllocHandle( SQL_HANDLE_STMT, hDbc, hStmt );
+
+    /* query */
+    nReturn = SQLExecDirect( hStmt, pszSQL, pszCommand, SQL_NTS );
+
+    /* fini */
+    nReturn = SQLFreeHandle( SQL_HANDLE_STMT, hStmt );
+    nReturn = SQLDisconnect( hDbc );
+    nReturn = SQLFreeHandle( SQL_HANDLE_DBC, hDbc );
+    nReturn = SQLFreeHandle( SQL_HANDLE_ENV, hEnv );
+
+    return( 0 );
+}
+

Added: trunk/Driver/examples/c/tutorial/tutorial_07.c
===================================================================
--- trunk/Driver/examples/c/tutorial/tutorial_07.c	2006-12-08 00:37:24 UTC (rev 712)
+++ trunk/Driver/examples/c/tutorial/tutorial_07.c	2006-12-08 00:47:20 UTC (rev 713)
@@ -0,0 +1,55 @@
+/*
+    Tutorial step 07.
+
+    In this step we provide an example of how to get the number of columns.
+*/
+#include <sql.h>
+#include <sqlext.h>
+
+int main( int argc, char *argv[] )
+{
+    SQLHENV     hEnv;
+    SQLHDBC     hDbc;
+    SQLHSTMT    hStm;
+    SQLRETURN   nReturn;
+    SQLCHAR *   pszDSN     = argv[1];
+    SQLCHAR *   pszUID     = argv[2];
+    SQLCHAR *   pszPWD     = argv[3];
+    SQLCHAR *   pszCommand = "INSERT INTO Tutorial ( nID, vcData ) " /
+                             "VALUES ( 1, \"data 1\" )             ";
+    SQLSMALLINT nColumns        = 0;
+
+    /* init */
+    nReturn = SQLSetEnvAttr( hEnv, SQL_ATTR_ODBC_VERSION, SQL_OV_ODBC3, 0 );
+    nReturn = SQLAllocHandle( SQL_HANDLE_DBC, hEnv, &hDbc );
+    nReturn = SQLConnect( hDbc, pszDSN, SQL_NTS, pszUID, SQL_NTS, pszPWD, SQL_NTS );
+    nReturn = SQLAllocHandle( SQL_HANDLE_STMT, hDbc, hStmt );
+    nReturn = SQLExecDirect( hStmt, pszSQL, pszCommand, SQL_NTS );
+    if ( !SQL_SUCCEEDED( nReturn ) )
+        goto exit1;
+
+    /* we have some form of result */
+
+    /* 
+        Get number of columns. 
+        A result may have a result-set (have columns) or may be just number of affected
rows.
+        Checking for 0 columns a good way to see if there is a result-set to process.
+        Most applications will know what type of result to expect based upon the command
they send to the data source.
+    */
+    nReturn = SQLNumResultCols( hStm, &nColumns );
+    if ( nColumns > 0 )
+        ; /* We have a result-set (may or may not have data). */
+    else
+        ; /* Result is just number of affected rows (should be 1 in this case). */
+
+exit1:
+    /* fini */
+    nReturn = SQLFreeHandle( SQL_HANDLE_STMT, hStmt );
+    nReturn = SQLDisconnect( hDbc );
+    nReturn = SQLFreeHandle( SQL_HANDLE_DBC, hDbc );
+    nReturn = SQLFreeHandle( SQL_HANDLE_ENV, hEnv );
+
+    return( 0 );
+}
+
+

Added: trunk/Driver/examples/c/tutorial/tutorial_08.c
===================================================================
--- trunk/Driver/examples/c/tutorial/tutorial_08.c	2006-12-08 00:37:24 UTC (rev 712)
+++ trunk/Driver/examples/c/tutorial/tutorial_08.c	2006-12-08 00:47:20 UTC (rev 713)
@@ -0,0 +1,52 @@
+/*
+    Tutorial step 08.
+
+    In this step we provide an example of how to get the number of affected rows.
+*/
+#include <sql.h>
+#include <sqlext.h>
+
+int main( int argc, char *argv[] )
+{
+    SQLHENV     hEnv;
+    SQLHDBC     hDbc;
+    SQLHSTMT    hStm;
+    SQLRETURN   nReturn;
+    SQLCHAR *   pszDSN     = argv[1];
+    SQLCHAR *   pszUID     = argv[2];
+    SQLCHAR *   pszPWD     = argv[3];
+    SQLCHAR *   pszCommand = "INSERT INTO Tutorial ( nID, vcData ) " /
+                             "VALUES ( 2, \"data 2\" )             ";
+    SQLSMALLINT nColumns        = 0;
+    SQLINTEGER  nAffectedRows   = -1;
+
+    /* init */
+    nReturn = SQLSetEnvAttr( hEnv, SQL_ATTR_ODBC_VERSION, SQL_OV_ODBC3, 0 );
+    nReturn = SQLAllocHandle( SQL_HANDLE_DBC, hEnv, &hDbc );
+    nReturn = SQLConnect( hDbc, pszDSN, SQL_NTS, pszUID, SQL_NTS, pszPWD, SQL_NTS );
+    nReturn = SQLAllocHandle( SQL_HANDLE_STMT, hDbc, hStmt );
+    nReturn = SQLExecDirect( hStmt, pszSQL, pszCommand, SQL_NTS );
+    if ( !SQL_SUCCEEDED( nReturn ) )
+        goto exit1;
+
+    /*
+        SQLRowCount is for returning number of affected rows (when result is not a
result-set).
+        The value returned when we have a result-set is 'driver defined' - sometimes
result-set rows.
+    */
+    nReturn = SQLRowCount( hStm, &nAffectedRows );
+    if ( nAffectedRows < 0 )
+        printf( "Number of rows affected could not be determined.\n" );
+    else
+        printf( "%ld rows affected\n", nAffectedRows );
+
+exit1:
+    /* fini */
+    nReturn = SQLFreeHandle( SQL_HANDLE_STMT, hStmt );
+    nReturn = SQLDisconnect( hDbc );
+    nReturn = SQLFreeHandle( SQL_HANDLE_DBC, hDbc );
+    nReturn = SQLFreeHandle( SQL_HANDLE_ENV, hEnv );
+
+    return( 0 );
+}
+
+

Added: trunk/Driver/examples/c/tutorial/tutorial_09.c
===================================================================
--- trunk/Driver/examples/c/tutorial/tutorial_09.c	2006-12-08 00:37:24 UTC (rev 712)
+++ trunk/Driver/examples/c/tutorial/tutorial_09.c	2006-12-08 00:47:20 UTC (rev 713)
@@ -0,0 +1,66 @@
+/*
+    Tutorial step 09.
+
+    In this step we provide an example of how to get the number of rows in a result-set.
+*/
+#include <sql.h>
+#include <sqlext.h>
+
+int main( int argc, char *argv[] )
+{
+    SQLHENV     hEnv;
+    SQLHDBC     hDbc;
+    SQLHSTMT    hStm;
+    SQLRETURN   nReturn;
+    SQLCHAR *   pszDSN     = argv[1];
+    SQLCHAR *   pszUID     = argv[2];
+    SQLCHAR *   pszPWD     = argv[3];
+    SQLCHAR *   pszCommand = "SELECT * " /
+                             "FROM   Tutorial";
+    SQLUINTEGER nForwardOnlyCursorAttributes2;
+    SQLINTEGER  nResultSetRows  = -1;
+
+    /* init */
+    nReturn = SQLSetEnvAttr( hEnv, SQL_ATTR_ODBC_VERSION, SQL_OV_ODBC3, 0 );
+    nReturn = SQLAllocHandle( SQL_HANDLE_DBC, hEnv, &hDbc );
+    nReturn = SQLConnect( hDbc, pszDSN, SQL_NTS, pszUID, SQL_NTS, pszPWD, SQL_NTS );
+    nReturn = SQLAllocHandle( SQL_HANDLE_STMT, hDbc, hStmt );
+
+    /* We want a forward-only cursor (most common). */
+    nReturn = SQLSetStmtAttr( hStm, SQL_ATTR_CURSOR_TYPE,
(SQLPOINTER)SQL_CURSOR_FORWARD_ONLY, 0 );
+
+    /* Get some driver capabilities for a forward-only cursor. */
+    nReturn = SQLGetInfo( hDbc, SQL_FORWARD_ONLY_CURSOR_ATTRIBUTES2,
&nForwardOnlyCursorAttributes2, SQL_IS_UINTEGER, 0 );  
+
+    nReturn = SQLExecDirect( hStmt, pszSQL, pszCommand, SQL_NTS );
+    if ( !SQL_SUCCEEDED( nReturn ) )
+        goto exit1;
+
+    /*
+        SQL_DIAG_CURSOR_ROW_COUNT is the exact or approximate number of rows in a
result-set.
+        Its accuracy depends upon the cursor type and the drivers features.
+        There are times when exact number can only be determined by fetching all rows.
+        This must be called after SQLExecute, SQLExecDirect, or SQLMoreResults.
+    */
+    nReturn = SQLGetDiagField( SQL_HANDLE_STMT, hStmt, 0, SQL_DIAG_CURSOR_ROW_COUNT,
&nResultSetRows, 0, 0 );
+
+    if ( nResultSetRows < 0 )
+        printf( "Could not determine ResultSetRows.\n" );
+    else if ( nForwardOnlyCursorAttributes2 & SQL_CA2_CRC_APPROXIMATE )
+        printf( "ResultSetRows is %ld and is an approximate value.\n", nResultSetRows );
+    else if ( nForwardOnlyCursorAttributes2 & SQL_CA2_CRC_EXACT )
+        printf( "ResultSetRows is %ld and is an exact value.\n", nResultSetRows );
+    else
+        printf( "ResultSetRows is %ld and may or may not be accurate.\n", nResultSetRows
);
+
+exit1:
+    /* fini */
+    nReturn = SQLFreeHandle( SQL_HANDLE_STMT, hStmt );
+    nReturn = SQLDisconnect( hDbc );
+    nReturn = SQLFreeHandle( SQL_HANDLE_DBC, hDbc );
+    nReturn = SQLFreeHandle( SQL_HANDLE_ENV, hEnv );
+
+    return( 0 );
+}
+
+

Added: trunk/Driver/examples/c/tutorial/tutorial_10.c
===================================================================
--- trunk/Driver/examples/c/tutorial/tutorial_10.c	2006-12-08 00:37:24 UTC (rev 712)
+++ trunk/Driver/examples/c/tutorial/tutorial_10.c	2006-12-08 00:47:20 UTC (rev 713)
@@ -0,0 +1,61 @@
+/*
+    Tutorial step 10.
+
+    In this step we provide an example of how to get data.
+*/
+#include <sql.h>
+#include <sqlext.h>
+
+#define DATA_MAX 255
+
+int main( int argc, char *argv[] )
+{
+    SQLHENV     hEnv;
+    SQLHDBC     hDbc;
+    SQLHSTMT    hStm;
+    SQLRETURN   nReturn;
+    SQLCHAR *   pszDSN     = argv[1];
+    SQLCHAR *   pszUID     = argv[2];
+    SQLCHAR *   pszPWD     = argv[3];
+    SQLCHAR *   pszCommand = "SELECT * " /
+                             "FROM   Tutorial";
+    SQLCHAR     szData[DATA_MAX + 1];
+    SQLINTEGER  nDataInd;
+    SQLINTEGER  nID;
+    SQLINTEGER  nIDInd;
+
+    /* init */
+    nReturn = SQLAllocHandle( SQL_HANDLE_ENV, NULL, &hEnv );
+    nReturn = SQLSetEnvAttr( hEnv, SQL_ATTR_ODBC_VERSION, SQL_OV_ODBC3, 0 );
+    nReturn = SQLAllocHandle( SQL_HANDLE_DBC, hEnv, &hDbc );
+    nReturn = SQLConnect( hDbc, pszDSN, SQL_NTS, pszUID, SQL_NTS, pszPWD, SQL_NTS );
+    nReturn = SQLAllocHandle( SQL_HANDLE_STMT, hDbc, hStmt );
+    nReturn = SQLExecDirect( hStmt, pszSQL, pszCommand, SQL_NTS );
+    if ( !SQL_SUCCEEDED( nReturn ) )
+        goto exit1;
+
+    /* fetch data */
+    while ( 1 ) 
+    {
+        nReturn = SQLFetch( hStmt );
+        if ( !SQL_SUCCEEDED( nReturn ) )
+            break;
+        nReturn = SQLGetData( hStmt, 1, SQL_C_LONG, nID, SQL_IS_INTEGER, &nIDInd );
+        nReturn = SQLGetData( hStmt, 2, SQL_C_CHAR, szData, DATA_MAX, &nDataInd );
+        if ( nIDInd == SQL_NULL_DATA )
+            printf( "NULL" );
+        else
+            printf( "%ld", nIDInd );
+        printf( " %s\n", ( nDataInd == SQL_NULL_DATA ? "NULL" : szData ) );
+   }
+
+exit1:
+    /* fini */
+    nReturn = SQLFreeHandle( SQL_HANDLE_STMT, hStmt );
+    nReturn = SQLDisconnect( hDbc );
+    nReturn = SQLFreeHandle( SQL_HANDLE_DBC, hDbc );
+    nReturn = SQLFreeHandle( SQL_HANDLE_ENV, hEnv );
+
+    return( 0 );
+}
+

Deleted: trunk/Driver/examples/c/tutorial_01.c
===================================================================
--- trunk/Driver/examples/c/tutorial_01.c	2006-12-08 00:37:24 UTC (rev 712)
+++ trunk/Driver/examples/c/tutorial_01.c	2006-12-08 00:47:20 UTC (rev 713)
@@ -1,31 +0,0 @@
-/*
-    Tutorial step 01.
-
-    In this step we provide an example of how to allocate an environment handle.
-*/
-#include <sql.h>
-#include <sqlext.h>
-
-int main( int argc, char *argv[] )
-{
-    SQLHENV     hEnv;
-    SQLRETURN   nReturn;
-
-    /* Allocate the environment handle. */
-    nReturn = SQLAllocHandle( SQL_HANDLE_ENV, NULL, &hEnv );
-    /* 
-        Tell the Driver Manager and/or Driver that we are expecting ODBC v3 behaviour. 
-        The default is ODBC v2 behaviour.
-        All new applications should set this to ODBC v3. 
-        This should be done before any connections are allocated.
-    */
-    nReturn = SQLSetEnvAttr( hEnv, SQL_ATTR_ODBC_VERSION, SQL_OV_ODBC3, 0 );
-
-    /* We normally do stuff here but lets just exit. */
-
-    /* Free resources used by the handle. */
-    nReturn = SQLFreeHandle( SQL_HANDLE_ENV, hEnv );
-
-    return( 0 );
-}
-

Deleted: trunk/Driver/examples/c/tutorial_02.c
===================================================================
--- trunk/Driver/examples/c/tutorial_02.c	2006-12-08 00:37:24 UTC (rev 712)
+++ trunk/Driver/examples/c/tutorial_02.c	2006-12-08 00:47:20 UTC (rev 713)
@@ -1,34 +0,0 @@
-/*
-    Tutorial step 02.
-
-    In this step we provide an example of how to allocate a connection handle.
-*/
-#include <sql.h>
-#include <sqlext.h>
-
-int main( int argc, char *argv[] )
-{
-    SQLHENV     hEnv;
-    SQLHDBC     hDbc;
-    SQLRETURN   nReturn;
-    
-    /* init */
-    nReturn = SQLAllocHandle( SQL_HANDLE_ENV, NULL, &hEnv );
-    nReturn = SQLSetEnvAttr( hEnv, SQL_ATTR_ODBC_VERSION, SQL_OV_ODBC3, 0 );
-
-    /* 
-        Allocate a connection handle. A single environment may have 0 or more
connections.
-    */
-    nReturn = SQLAllocHandle( SQL_HANDLE_DBC, hEnv, &hDbc );
-
-    /* We normally do stuff here but lets just exit. */
-
-    /* Free resources used by the handle. */
-    nReturn = SQLFreeHandle( SQL_HANDLE_DBC, hDbc );
-
-    /* fini */
-    nReturn = SQLFreeHandle( SQL_HANDLE_ENV, hEnv );
-
-    return( 0 );
-}
-

Deleted: trunk/Driver/examples/c/tutorial_03.c
===================================================================
--- trunk/Driver/examples/c/tutorial_03.c	2006-12-08 00:37:24 UTC (rev 712)
+++ trunk/Driver/examples/c/tutorial_03.c	2006-12-08 00:47:20 UTC (rev 713)
@@ -1,37 +0,0 @@
-/*
-    Tutorial step 03.
-
-    In this step we provide an example of how to connect to a data source.
-*/
-#include <sql.h>
-#include <sqlext.h>
-
-int main( int argc, char *argv[] )
-{
-    SQLHENV     hEnv;
-    SQLHDBC     hDbc;
-    SQLRETURN   nReturn;
-    SQLCHAR *   pszDSN  = argv[1]; /* An existing DSN usually created by "ODBCConfig" or
"ODBC Administrator". */
-    SQLCHAR *   pszUID  = argv[2];
-    SQLCHAR *   pszPWD  = argv[3];
-
-    /* init */
-    nReturn = SQLAllocHandle( SQL_HANDLE_ENV, NULL, &hEnv );
-    nReturn = SQLSetEnvAttr( hEnv, SQL_ATTR_ODBC_VERSION, SQL_OV_ODBC3, 0 );
-    nReturn = SQLAllocHandle( SQL_HANDLE_DBC, hEnv, &hDbc );
-
-    /* Connect using an existing DSN. */
-    nReturn = SQLConnect( hDbc, pszDSN, SQL_NTS, pszUID, SQL_NTS, pszPWD, SQL_NTS );
-
-    /* We normally do stuff here but lets just exit. */
-
-    /* Disconnect. */
-    nReturn = SQLDisconnect( hDbc );
-
-    /* fini */
-    nReturn = SQLFreeHandle( SQL_HANDLE_DBC, hDbc );
-    nReturn = SQLFreeHandle( SQL_HANDLE_ENV, hEnv );
-
-    return( 0 );
-}
-

Deleted: trunk/Driver/examples/c/tutorial_04.c
===================================================================
--- trunk/Driver/examples/c/tutorial_04.c	2006-12-08 00:37:24 UTC (rev 712)
+++ trunk/Driver/examples/c/tutorial_04.c	2006-12-08 00:47:20 UTC (rev 713)
@@ -1,79 +0,0 @@
-/*
-    Tutorial step 04.
-
-    In this step we provide an example of how to get diagnostic information.
-*/
-#include <sql.h>
-#include <sqlext.h>
-
-void dumpDiagnostics( SQLSMALLINT nHandleType, SQLHANDLE hHandle )
-{
-    SQLSMALLINT nRecord = 1;
-    SQLWCHAR    sState[6];
-    SQLINTEGER  nNativeError;
-    SQLWCHAR    sMessageText[SQL_MAX_MESSAGE_LENGTH];
-    SQLSMALLINT nTextLength;
-
-    /*
-        The oldest diagnostic record will be 1. The driver is only obligated to
-        return up to 8 records but most will return more (as needed). 
-
-        We loop through all records - printing them to stdout.
-
-        We use the SQL_SUCCEED macro to tell us if we have a SQL_SUCCESS
-        or SQL_SUCCESS_WITH_INFO. We expect to break out of loop when
-        SQLGetDiagRec returns SQL_NO_DATA.
-    */
-    while ( SQL_SUCCEEDED( SQLGetDiagRec( nHandleType, 
-                                          hHandle, 
-                                          nRecord, 
-                                          sState,
-                                          &nNativeError,
-                                          sMessageText,
-                                          SQL_MAX_MESSAGE_LENGTH,
-                                          &nTextLength )) )
-    {
-        sState[5] = '\0';
-        printf( "[%s][%d] %s\n", sState, nNativeError, sMessageText );
-        nRecord++;
-    }
-}
-
-int main( int argc, char *argv[] )
-{
-    SQLHENV     hEnv;
-    SQLHDBC     hDbc;
-    SQLRETURN   nReturn;
-    SQLCHAR *   pszDSN  = argv[1]; /* An existing DSN usually created by "ODBCConfig" or
"ODBC Administrator". */
-    SQLCHAR *   pszUID  = argv[2];
-    SQLCHAR *   pszPWD  = argv[3];
-
-    /* init */
-    nReturn = SQLAllocHandle( SQL_HANDLE_ENV, NULL, &hEnv );
-    nReturn = SQLSetEnvAttr( hEnv, SQL_ATTR_ODBC_VERSION, SQL_OV_ODBC3, 0 );
-    nReturn = SQLAllocHandle( SQL_HANDLE_DBC, hEnv, &hDbc );
-    nReturn = SQLConnect( hDbc, pszDSN, SQL_NTS, pszUID, SQL_NTS, pszPWD, SQL_NTS );
-
-    /* Check return code to see how things went for the last ODBC call. */
-    switch ( nReturn )
-    {
-        case SQL_ERROR:
-            dumpDiagnostics( SQL_HANDLE_DBC, hDbc );
-            goto exit1;
-        case SQL_SUCCESS_WITH_INFO:
-            dumpDiagnostics( SQL_HANDLE_DBC, hDbc );
-            break;
-    }
-
-    /* We normally do stuff here but lets just exit. */
-
-    nReturn = SQLDisconnect( hDbc );
-
-exit1:
-    /* fini */
-    nReturn = SQLFreeHandle( SQL_HANDLE_DBC, hDbc );
-    nReturn = SQLFreeHandle( SQL_HANDLE_ENV, hEnv );
-
-    return( 0 );
-}
-

Deleted: trunk/Driver/examples/c/tutorial_05.c
===================================================================
--- trunk/Driver/examples/c/tutorial_05.c	2006-12-08 00:37:24 UTC (rev 712)
+++ trunk/Driver/examples/c/tutorial_05.c	2006-12-08 00:47:20 UTC (rev 713)
@@ -1,42 +0,0 @@
-/*
-    Tutorial step 05.
-
-    In this step we provide an example of how to allocate a statement handle.
-*/
-#include <sql.h>
-#include <sqlext.h>
-
-int main( int argc, char *argv[] )
-{
-    SQLHENV     hEnv;
-    SQLHDBC     hDbc;
-    SQLHSTMT    hStm;
-    SQLRETURN   nReturn;
-    SQLCHAR *   pszDSN  = argv[1];
-    SQLCHAR *   pszUID  = argv[2];
-    SQLCHAR *   pszPWD  = argv[3];
-
-    /* init */
-    nReturn = SQLAllocHandle( SQL_HANDLE_ENV, NULL, &hEnv );
-    nReturn = SQLSetEnvAttr( hEnv, SQL_ATTR_ODBC_VERSION, SQL_OV_ODBC3, 0 );
-    nReturn = SQLAllocHandle( SQL_HANDLE_DBC, hEnv, &hDbc );
-    nReturn = SQLConnect( hDbc, pszDSN, SQL_NTS, pszUID, SQL_NTS, pszPWD, SQL_NTS );
-
-    /* 
-        Allocate a statement handle. A single connection may have 0 or more statements.
-    */
-    nReturn = SQLAllocHandle( SQL_HANDLE_STMT, hDbc, hStmt );
-
-    /* We normally do stuff here but lets just exit. */
-
-    /* Free resources used by the handle. */
-    nReturn = SQLFreeHandle( SQL_HANDLE_STMT, hStm );
-
-    /* fini */
-    nReturn = SQLDisconnect( hDbc );
-    nReturn = SQLFreeHandle( SQL_HANDLE_DBC, hDbc );
-    nReturn = SQLFreeHandle( SQL_HANDLE_ENV, hEnv );
-
-    return( 0 );
-}
-

Deleted: trunk/Driver/examples/c/tutorial_06.c
===================================================================
--- trunk/Driver/examples/c/tutorial_06.c	2006-12-08 00:37:24 UTC (rev 712)
+++ trunk/Driver/examples/c/tutorial_06.c	2006-12-08 00:47:20 UTC (rev 713)
@@ -1,41 +0,0 @@
-/*
-    Tutorial step 06.
-
-    In this step we provide an example of how to submit a command to the data source.
-*/
-#include <sql.h>
-#include <sqlext.h>
-
-int main( int argc, char *argv[] )
-{
-    SQLHENV     hEnv;
-    SQLHDBC     hDbc;
-    SQLHSTMT    hStm;
-    SQLRETURN   nReturn;
-    SQLCHAR *   pszDSN     = argv[1];
-    SQLCHAR *   pszUID     = argv[2];
-    SQLCHAR *   pszPWD     = argv[3];
-    SQLCHAR *   pszCommand = "CREATE TABLE Tutorial AS " /
-                             "(                        " /
-                             "   nID    NUMERIC(6),    " /
-                             "   vcData VARCHAR(50)    " /
-                             ")                        ";
-
-    /* init */
-    nReturn = SQLSetEnvAttr( hEnv, SQL_ATTR_ODBC_VERSION, SQL_OV_ODBC3, 0 );
-    nReturn = SQLAllocHandle( SQL_HANDLE_DBC, hEnv, &hDbc );
-    nReturn = SQLConnect( hDbc, pszDSN, SQL_NTS, pszUID, SQL_NTS, pszPWD, SQL_NTS );
-    nReturn = SQLAllocHandle( SQL_HANDLE_STMT, hDbc, hStmt );
-
-    /* query */
-    nReturn = SQLExecDirect( hStmt, pszSQL, pszCommand, SQL_NTS );
-
-    /* fini */
-    nReturn = SQLFreeHandle( SQL_HANDLE_STMT, hStmt );
-    nReturn = SQLDisconnect( hDbc );
-    nReturn = SQLFreeHandle( SQL_HANDLE_DBC, hDbc );
-    nReturn = SQLFreeHandle( SQL_HANDLE_ENV, hEnv );
-
-    return( 0 );
-}
-

Deleted: trunk/Driver/examples/c/tutorial_07.c
===================================================================
--- trunk/Driver/examples/c/tutorial_07.c	2006-12-08 00:37:24 UTC (rev 712)
+++ trunk/Driver/examples/c/tutorial_07.c	2006-12-08 00:47:20 UTC (rev 713)
@@ -1,55 +0,0 @@
-/*
-    Tutorial step 07.
-
-    In this step we provide an example of how to get the number of columns.
-*/
-#include <sql.h>
-#include <sqlext.h>
-
-int main( int argc, char *argv[] )
-{
-    SQLHENV     hEnv;
-    SQLHDBC     hDbc;
-    SQLHSTMT    hStm;
-    SQLRETURN   nReturn;
-    SQLCHAR *   pszDSN     = argv[1];
-    SQLCHAR *   pszUID     = argv[2];
-    SQLCHAR *   pszPWD     = argv[3];
-    SQLCHAR *   pszCommand = "INSERT INTO Tutorial ( nID, vcData ) " /
-                             "VALUES ( 1, \"data 1\" )             ";
-    SQLSMALLINT nColumns        = 0;
-
-    /* init */
-    nReturn = SQLSetEnvAttr( hEnv, SQL_ATTR_ODBC_VERSION, SQL_OV_ODBC3, 0 );
-    nReturn = SQLAllocHandle( SQL_HANDLE_DBC, hEnv, &hDbc );
-    nReturn = SQLConnect( hDbc, pszDSN, SQL_NTS, pszUID, SQL_NTS, pszPWD, SQL_NTS );
-    nReturn = SQLAllocHandle( SQL_HANDLE_STMT, hDbc, hStmt );
-    nReturn = SQLExecDirect( hStmt, pszSQL, pszCommand, SQL_NTS );
-    if ( !SQL_SUCCEEDED( nReturn ) )
-        goto exit1;
-
-    /* we have some form of result */
-
-    /* 
-        Get number of columns. 
-        A result may have a result-set (have columns) or may be just number of affected
rows.
-        Checking for 0 columns a good way to see if there is a result-set to process.
-        Most applications will know what type of result to expect based upon the command
they send to the data source.
-    */
-    nReturn = SQLNumResultCols( hStm, &nColumns );
-    if ( nColumns > 0 )
-        ; /* We have a result-set (may or may not have data). */
-    else
-        ; /* Result is just number of affected rows (should be 1 in this case). */
-
-exit1:
-    /* fini */
-    nReturn = SQLFreeHandle( SQL_HANDLE_STMT, hStmt );
-    nReturn = SQLDisconnect( hDbc );
-    nReturn = SQLFreeHandle( SQL_HANDLE_DBC, hDbc );
-    nReturn = SQLFreeHandle( SQL_HANDLE_ENV, hEnv );
-
-    return( 0 );
-}
-
-

Deleted: trunk/Driver/examples/c/tutorial_08.c
===================================================================
--- trunk/Driver/examples/c/tutorial_08.c	2006-12-08 00:37:24 UTC (rev 712)
+++ trunk/Driver/examples/c/tutorial_08.c	2006-12-08 00:47:20 UTC (rev 713)
@@ -1,52 +0,0 @@
-/*
-    Tutorial step 08.
-
-    In this step we provide an example of how to get the number of affected rows.
-*/
-#include <sql.h>
-#include <sqlext.h>
-
-int main( int argc, char *argv[] )
-{
-    SQLHENV     hEnv;
-    SQLHDBC     hDbc;
-    SQLHSTMT    hStm;
-    SQLRETURN   nReturn;
-    SQLCHAR *   pszDSN     = argv[1];
-    SQLCHAR *   pszUID     = argv[2];
-    SQLCHAR *   pszPWD     = argv[3];
-    SQLCHAR *   pszCommand = "INSERT INTO Tutorial ( nID, vcData ) " /
-                             "VALUES ( 2, \"data 2\" )             ";
-    SQLSMALLINT nColumns        = 0;
-    SQLINTEGER  nAffectedRows   = -1;
-
-    /* init */
-    nReturn = SQLSetEnvAttr( hEnv, SQL_ATTR_ODBC_VERSION, SQL_OV_ODBC3, 0 );
-    nReturn = SQLAllocHandle( SQL_HANDLE_DBC, hEnv, &hDbc );
-    nReturn = SQLConnect( hDbc, pszDSN, SQL_NTS, pszUID, SQL_NTS, pszPWD, SQL_NTS );
-    nReturn = SQLAllocHandle( SQL_HANDLE_STMT, hDbc, hStmt );
-    nReturn = SQLExecDirect( hStmt, pszSQL, pszCommand, SQL_NTS );
-    if ( !SQL_SUCCEEDED( nReturn ) )
-        goto exit1;
-
-    /*
-        SQLRowCount is for returning number of affected rows (when result is not a
result-set).
-        The value returned when we have a result-set is 'driver defined' - sometimes
result-set rows.
-    */
-    nReturn = SQLRowCount( hStm, &nAffectedRows );
-    if ( nAffectedRows < 0 )
-        printf( "Number of rows affected could not be determined.\n" );
-    else
-        printf( "%ld rows affected\n", nAffectedRows );
-
-exit1:
-    /* fini */
-    nReturn = SQLFreeHandle( SQL_HANDLE_STMT, hStmt );
-    nReturn = SQLDisconnect( hDbc );
-    nReturn = SQLFreeHandle( SQL_HANDLE_DBC, hDbc );
-    nReturn = SQLFreeHandle( SQL_HANDLE_ENV, hEnv );
-
-    return( 0 );
-}
-
-

Deleted: trunk/Driver/examples/c/tutorial_09.c
===================================================================
--- trunk/Driver/examples/c/tutorial_09.c	2006-12-08 00:37:24 UTC (rev 712)
+++ trunk/Driver/examples/c/tutorial_09.c	2006-12-08 00:47:20 UTC (rev 713)
@@ -1,66 +0,0 @@
-/*
-    Tutorial step 09.
-
-    In this step we provide an example of how to get the number of rows in a result-set.
-*/
-#include <sql.h>
-#include <sqlext.h>
-
-int main( int argc, char *argv[] )
-{
-    SQLHENV     hEnv;
-    SQLHDBC     hDbc;
-    SQLHSTMT    hStm;
-    SQLRETURN   nReturn;
-    SQLCHAR *   pszDSN     = argv[1];
-    SQLCHAR *   pszUID     = argv[2];
-    SQLCHAR *   pszPWD     = argv[3];
-    SQLCHAR *   pszCommand = "SELECT * " /
-                             "FROM   Tutorial";
-    SQLUINTEGER nForwardOnlyCursorAttributes2;
-    SQLINTEGER  nResultSetRows  = -1;
-
-    /* init */
-    nReturn = SQLSetEnvAttr( hEnv, SQL_ATTR_ODBC_VERSION, SQL_OV_ODBC3, 0 );
-    nReturn = SQLAllocHandle( SQL_HANDLE_DBC, hEnv, &hDbc );
-    nReturn = SQLConnect( hDbc, pszDSN, SQL_NTS, pszUID, SQL_NTS, pszPWD, SQL_NTS );
-    nReturn = SQLAllocHandle( SQL_HANDLE_STMT, hDbc, hStmt );
-
-    /* We want a forward-only cursor (most common). */
-    nReturn = SQLSetStmtAttr( hStm, SQL_ATTR_CURSOR_TYPE,
(SQLPOINTER)SQL_CURSOR_FORWARD_ONLY, 0 );
-
-    /* Get some driver capabilities for a forward-only cursor. */
-    nReturn = SQLGetInfo( hDbc, SQL_FORWARD_ONLY_CURSOR_ATTRIBUTES2,
&nForwardOnlyCursorAttributes2, SQL_IS_UINTEGER, 0 );  
-
-    nReturn = SQLExecDirect( hStmt, pszSQL, pszCommand, SQL_NTS );
-    if ( !SQL_SUCCEEDED( nReturn ) )
-        goto exit1;
-
-    /*
-        SQL_DIAG_CURSOR_ROW_COUNT is the exact or approximate number of rows in a
result-set.
-        Its accuracy depends upon the cursor type and the drivers features.
-        There are times when exact number can only be determined by fetching all rows.
-        This must be called after SQLExecute, SQLExecDirect, or SQLMoreResults.
-    */
-    nReturn = SQLGetDiagField( SQL_HANDLE_STMT, hStmt, 0, SQL_DIAG_CURSOR_ROW_COUNT,
&nResultSetRows, 0, 0 );
-
-    if ( nResultSetRows < 0 )
-        printf( "Could not determine ResultSetRows.\n" );
-    else if ( nForwardOnlyCursorAttributes2 & SQL_CA2_CRC_APPROXIMATE )
-        printf( "ResultSetRows is %ld and is an approximate value.\n", nResultSetRows );
-    else if ( nForwardOnlyCursorAttributes2 & SQL_CA2_CRC_EXACT )
-        printf( "ResultSetRows is %ld and is an exact value.\n", nResultSetRows );
-    else
-        printf( "ResultSetRows is %ld and may or may not be accurate.\n", nResultSetRows
);
-
-exit1:
-    /* fini */
-    nReturn = SQLFreeHandle( SQL_HANDLE_STMT, hStmt );
-    nReturn = SQLDisconnect( hDbc );
-    nReturn = SQLFreeHandle( SQL_HANDLE_DBC, hDbc );
-    nReturn = SQLFreeHandle( SQL_HANDLE_ENV, hEnv );
-
-    return( 0 );
-}
-
-

Deleted: trunk/Driver/examples/c/tutorial_10.c
===================================================================
--- trunk/Driver/examples/c/tutorial_10.c	2006-12-08 00:37:24 UTC (rev 712)
+++ trunk/Driver/examples/c/tutorial_10.c	2006-12-08 00:47:20 UTC (rev 713)
@@ -1,61 +0,0 @@
-/*
-    Tutorial step 10.
-
-    In this step we provide an example of how to get data.
-*/
-#include <sql.h>
-#include <sqlext.h>
-
-#define DATA_MAX 255
-
-int main( int argc, char *argv[] )
-{
-    SQLHENV     hEnv;
-    SQLHDBC     hDbc;
-    SQLHSTMT    hStm;
-    SQLRETURN   nReturn;
-    SQLCHAR *   pszDSN     = argv[1];
-    SQLCHAR *   pszUID     = argv[2];
-    SQLCHAR *   pszPWD     = argv[3];
-    SQLCHAR *   pszCommand = "SELECT * " /
-                             "FROM   Tutorial";
-    SQLCHAR     szData[DATA_MAX + 1];
-    SQLINTEGER  nDataInd;
-    SQLINTEGER  nID;
-    SQLINTEGER  nIDInd;
-
-    /* init */
-    nReturn = SQLAllocHandle( SQL_HANDLE_ENV, NULL, &hEnv );
-    nReturn = SQLSetEnvAttr( hEnv, SQL_ATTR_ODBC_VERSION, SQL_OV_ODBC3, 0 );
-    nReturn = SQLAllocHandle( SQL_HANDLE_DBC, hEnv, &hDbc );
-    nReturn = SQLConnect( hDbc, pszDSN, SQL_NTS, pszUID, SQL_NTS, pszPWD, SQL_NTS );
-    nReturn = SQLAllocHandle( SQL_HANDLE_STMT, hDbc, hStmt );
-    nReturn = SQLExecDirect( hStmt, pszSQL, pszCommand, SQL_NTS );
-    if ( !SQL_SUCCEEDED( nReturn ) )
-        goto exit1;
-
-    /* fetch data */
-    while ( 1 ) 
-    {
-        nReturn = SQLFetch( hStmt );
-        if ( !SQL_SUCCEEDED( nReturn ) )
-            break;
-        nReturn = SQLGetData( hStmt, 1, SQL_C_LONG, nID, SQL_IS_INTEGER, &nIDInd );
-        nReturn = SQLGetData( hStmt, 2, SQL_C_CHAR, szData, DATA_MAX, &nDataInd );
-        if ( nIDInd == SQL_NULL_DATA )
-            printf( "NULL" );
-        else
-            printf( "%ld", nIDInd );
-        printf( " %s\n", ( nDataInd == SQL_NULL_DATA ? "NULL" : szData ) );
-   }
-
-exit1:
-    /* fini */
-    nReturn = SQLFreeHandle( SQL_HANDLE_STMT, hStmt );
-    nReturn = SQLDisconnect( hDbc );
-    nReturn = SQLFreeHandle( SQL_HANDLE_DBC, hDbc );
-    nReturn = SQLFreeHandle( SQL_HANDLE_ENV, hEnv );
-
-    return( 0 );
-}
-

Copied: trunk/Driver/examples/vb7 (from rev 705, trunk/Driver/examples/vb)

Thread
Connector/ODBC 5 commit: r713 - in trunk/Driver/examples: . c c/tutorialpharvey8 Dec