3

I just wrote a simple function, that creates me a INSERT string out of the input the user has made, so I get something like this(working with ionic btw):

    INSERT INTO people(firstname, lastname) VALUES (??)

Now I would like to use a Array that holds the inputvalues as parameter:

let inputvalues = ["value1", "value2"];
    this.database.executeSql(this.createInserString("people",this.userData), [inputvalues]).then((data) => {
        console.log("INSERTED: " + JSON.stringify(data));
    }, (error) => {
        console.log("ERROR-Insert: " + JSON.stringify(error.err));
    });

Is there a way to implement something like this? (because otherwise I have to type out ever single input values and ... there are a lot ;-( )

Thank you!

1 Answer 1

4
+50

i think you should separate parameters with comma:

INSERT INTO people(firstname, lastname) VALUES (?,?)

and then use the array without "[ ]" since its already an array:

this.database.executeSql(this.createInserString("people",this.userData), inputvalues)
Sign up to request clarification or add additional context in comments.

1 Comment

Uh jeah, the comma was just a typo ;-) Thank you, that worked! Now I feel stupid ;D

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.