MySQL Forums :: Connector/Arduino :: inserting a string variable


Advanced Search

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 1907 Steve Spence 09/21/2014 08:49AM
Re: inserting a string variable 980 Steve Spence 09/21/2014 08:54AM
Re: inserting a string variable 921 Steve Spence 09/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.