]> git.saurik.com Git - wxWidgets.git/commitdiff
Added examples of an INSERT and a DELETE to the sample application that is part of...
authorGeorge Tasker <gtasker@allenbrook.com>
Mon, 27 Oct 2003 23:43:54 +0000 (23:43 +0000)
committerGeorge Tasker <gtasker@allenbrook.com>
Mon, 27 Oct 2003 23:43:54 +0000 (23:43 +0000)
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@24329 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775

docs/latex/wx/tdb.tex

index b70ebba29d737586d8788dbcdc7058982ab50bcc..7a2d7be7fca25e3b0450bd8a4e6185a384c58b4f 100644 (file)
@@ -977,9 +977,9 @@ table->SetColDefs(1, "LAST_NAME", DB_DATA_TYPE_VARCHAR, LastName,
 // Open the table for access
 table->Open();
 
-// Set the WHERE clause to limit the result set to only
-// return all rows that have a value of 'GEORGE' in the
-// FIRST_NAME column of the table.
+// Set the WHERE clause to limit the result set to return
+// all rows that have a value of 'GEORGE' in the FIRST_NAME
+// column of the table.
 table->SetWhereClause("FIRST_NAME = 'GEORGE'");
 
 // Result set will be sorted in ascending alphabetical 
@@ -1009,12 +1009,37 @@ while (table->GetNext())
     wxMessageBox(msg, "Data", wxOK | wxICON_INFORMATION, NULL);
 }
 
+
+//
+// Select the row which has FIRST_NAME of 'GEORGE' and LAST_NAME
+// of 'TASKER', then delete the retrieved row
+//
+table->SetWhereClause("FIRST_NAME = 'GEORGE' and "LAST_NAME = 'TASKER'");
+if (table->Query())
+{
+    table->Delete();
+       
+       // Must commit the deletion
+       table->GetDb()->CommitTrans();
+}
+
+
+//
+// Insert a new row into the table
+//
+wxStrcpy(FirstName, "JULIAN");
+wxStrcpy(LastName, "SMART");
+table->Insert();
+
+// Must commit the insert
+table->GetDb()->CommitTrans();
+
+
 // If the wxDbTable instance was successfully created
-// then delete it as I am done with it now.
+// then delete it as we are done with it now.
 if (table)
 {
-    delete table;
-    table = NULL;
+    wxDelete(table);
 }
 
 // If we have a valid wxDb instance, then free the connection
@@ -1034,7 +1059,7 @@ wxDbCloseConnections();
 
 // Release the environment handle that was created
 // for use with the ODBC datasource connections
-delete DbConnectInf;
+wxDelete(DbConnectInf);
 
 \end{verbatim}