0

I'm working on a small project (my first MySQL one) and I got to a point where I'm coding a query to insert data in a table.

These are my variables:

float min=0, max=0, med=0, aux;
string data, stringTipo, stringPapel, stringCompanhia;

I converted the std::strings to System::strings using:

String^ sCom = gcnew String(stringCompanhia.c_str());
String^ sTipo = gcnew String(stringTipo.c_str());
String^ sPap = gcnew String(stringPapel.c_str());
String^ sDat = gcnew String(data.c_str());

This is my query:

MySqlCommand^ cmdDataBase=gcnew MySqlCommand("insert into bdi.acoes (companhia,papel,tipo,min,max,med,data) values('"+sCom+"','"+sPap,+"','"+sTipo+"','"+min+"','"+max+"','"+med+"','"+sDat+"');",conDataBase);

As of now, I'm working on a query to insert data, stringTipo, stringPapel, stringCompanhia, min, max and med into my acoes table.

For now I got errors related to the floats only, I do BELIEVE that my string conversion is rather fine for inserting data into my query, but any suggestions are welcome.

These are the errors I'm getting (note: all of them are the same for all floats).

error C2678: binary '+' : no operator found which takes a left-hand operand of type 'const char [4]' (or there is no acceptable conversion)

Brian Tompsett - 汤莱恩
  • 5,753
  • 72
  • 57
  • 129
Heinzen
  • 173
  • 1
  • 13
  • possible duplicate of [How can i concatenate float with string?](http://stackoverflow.com/questions/15385378/how-can-i-concatenate-float-with-string) – Brian S Feb 05 '14 at 21:42
  • 1
    The problem is that you're trying to perform `string+float`, which C++ doesn't like. This error has nothing to do with SQL. – Brian S Feb 05 '14 at 21:43

0 Answers0