Menu

#85 escaping doesnt work (not with attachment)

open
nobody
None
5
2004-02-13
2004-02-13
Anonymous
No

Escape-ing doesnt work correct
Code(which already contains an work around):
============================================
String insertSql = "INSERT INTO messages(Id,
Subject, Header, Body, Date)";
insertSql += "VALUES (@ID, @SUBJECT,@HEADER, @BODY,
@DATE)";

MySqlCommand insertCommand = new
MySqlCommand(insertSql, m_Connection);
insertCommand.Parameters.Add("@ID", key);
insertCommand.Parameters.Add("@SUBJECT", subject);
insertCommand.Parameters.Add("@HEADER", header);
// START WORK AROUND!
// maybe the value is too large,.. trim them if
nessecary
// 10.000 sounds enough to me!
// Otherwise the mysql driver fails with network
exception
// hack hack
if(body.Length > 10000) body = body.Substring(1,10000);
// STOP WORK AROUND!
insertCommand.Parameters.Add("@BODY", body);
insertCommand.Parameters.Add("@DATE", date);

Error:

An unhandled exception of type
'ByteFX.Data.MySqlClient.MySqlException' occurred in
bytefx.data.dll

Additional information: You have an error in your SQL
syntax. Check the manual that corresponds to your
MySQL server version for the right syntax to use near
'`\"+\" ``
MSP@``- (``#1\" ``ZP@``&\*``\"4\"@``E0H``)8*``\"W\"@`

20040213sourceforge.netATnergensDOTorg

Discussion


Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.