Menu

#33 Parameter Exception on String Parameter type

open
nobody
None
5
2007-09-28
2007-09-28
Anonymous
No

Your signatur to call "mysql_real_escape_string" is not correct!

[ DllImport( "libmySQL.dll", EntryPoint="mysql_real_escape_string" )]
unsafe public static extern ulong mysql_real_escape_string(void *mysql, System.Text.StringBuilder to, string from, ulong length);

-> ulong is a 64 bit value (.Net) but in C/C++ is ulong a 32 bit value.

uint is the correct value to works fine in:
"unsafe internal static string Escape(string str, MySQLConnection conn)"

#MySqlUtil.cs#
CPrototypes.mysql_real_escape_string(conn.Handle, to, str, (uint)bytes.Length);

#CPrototypes.cs#
[ DllImport( "libmySQL.dll", EntryPoint="mysql_real_escape_string" )]
unsafe public static extern ulong mysql_real_escape_string(void *mysql, System.Text.StringBuilder to, string from, uint length);

Very good project, nice
Thomas

Discussion


Log in to post a comment.