Felipe Marks

Felipe Marks

  • NA
  • 76
  • 0

insert strings using mysql ODBC

Jan 19 2010 3:42 AM
Hi

I have a problem with inserting strings.

I'm using MySql with a ODBC connection.

eg:

code = "mycode";
desc = "It's not working";

string sql = "";
sql = "insert into pasCustomerCodes(code,description) values('" + code + "','" + desc + "')";

OdbcCom = new System.Data.Odbc.OdbcCommand(sql, OdbcCon);
OdbcCom.ExecuteNonQuery();

---------

This gives an erro because of the ' character in the desc string.
Is there anything I can use to fix this?

Thanks

Answers (3)