Posted on 2012-08-14
Last Modified: 2012-08-15
Does anyone have examples of working ADBC SQL INSERT and UPDATE statements?  I can't get any of the syntax to work. I'm guessing the problem is with single vs double quotes and setting values.

// Globals
var dbName = "TestDB";
var dbConn = null;
var stmtObj = null;
var test1 = "TEST";
var test2 = "TestBad";

//this is the easy part that works:
var sqlToExecute = "Select * from Customers";

//this is with outside single quotes
var sqlToExecute2 = 'INSERT INTO "Customers" ("CustomerID", "FullName", "NumGoodParts", "NumReject", "RejectCode") VALUES ( 7, test1, 9, 1, test2)';

var sqlToExecute3 = 'UPDATE "Customers" Set "FullName" = test1, "NumGoodParts" = 9, "NumReject" = 1; "RejectCode" = test2 WHERE "CustomerID" = 6';

//this is with outside double quotes
var sqlToExecute2 = "INSERT INTO Customers (CustomerID, FullName, NumGoodParts, NumReject, RejectCode) VALUES ( 7, test1, 9, 1, test2)";

var sqlToExecute3 = "UPDATE Customers Set FullName = test1, NumGoodParts = 9, NumReject = 1; RejectCode = test2 WHERE CustomerID = 6';

function save()
    //first connect to the database
    app.alert("Attempting Connection...");
    dbConn = ADBC.newConnection(dbName);
    if(dbConn == null)
       throw "Error connecting";

    stmtObj = dbConn.newStatement();

    // Execute the SQL statement inside the database

    throw "Unable to Connect to Database";


Question by:telefunken
    LVL 48

    Accepted Solution

    Try with:

    var sqlToExecute2 = "INSERT INTO Customers (CustomerID, FullName, NumGoodParts, NumReject, RejectCode) VALUES ( 7, '" + test1 + "', 9, 1, '" + test2 + "')";

    var sqlToExecute3 = "UPDATE Customers Set FullName = '" + test1 + "', NumGoodParts = 9, NumReject = 1, RejectCode = '" + test2 + "' WHERE CustomerID = 6";


    Author Closing Comment

    This is pesky syntax, platform to platform, so appreciate the VERY QUICK and ON TARGET response!
    LVL 48

    Expert Comment

    by:Gustav Brock


    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    Do You Know the 4 Main Threat Actor Types?

    Do you know the main threat actor types? Most attackers fall into one of four categories, each with their own favored tactics, techniques, and procedures.

    The Adobe PDF proprietary file format is recognized as secure and formulated. But these PDF files are also prone to corruption and any external threat like virus attacks, improper storage can hit PDF file integrity.This type of damages can make cruc…
    A short article about a problem I had getting the GPS LocationListener working.
    Viewers will learn how to properly install Eclipse with the necessary JDK, and will take a look at an introductory Java program. Download Eclipse installation zip file: Extract files from zip file: Download and install JDK 8: Open Eclipse and …
    In this fifth video of the Xpdf series, we discuss and demonstrate the PDFdetach utility, which is able to list and, more importantly, extract attachments that are embedded in PDF files. It does this via a command line interface, making it suitable …

    760 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    9 Experts available now in Live!

    Get 1:1 Help Now