MySQL Forums
Forum List  »  Connector/Arduino

inserting a string variable
Posted by: Steve Spence
Date: September 21, 2014 08:49AM

I'm trying to insert a string (5 byte hex) into the database.

I've tried:


String stringOne = "2d144bf28";

sprintf(buf, "INSERT INTO database.table VALUES (%s)", stringOne);

and

char* stringOne[ ] = {"2d144bf28"};

sprintf(buf, "INSERT INTO database.table VALUES (%s)", stringOne[0]);

Neither works.

First one hangs the sketch, second example gives "Error: 51 = Unknown column '2d144bf28' in 'field list'."

however;

int stringOne = 1234;

sprintf(buf, "INSERT INTO database.table VALUES (%i)", stringOne);

works fine.

Options: ReplyQuote


Subject
Views
Written By
Posted
inserting a string variable
4995
September 21, 2014 08:49AM
1919
September 21, 2014 08:54AM
1826
September 21, 2014 12:18PM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.