Bug #48457 .ToString returns System.Byte[]
| Submitted: | 1 Nov 2009 22:55 | Modified: | 2 Nov 2009 21:54 |
|---|---|---|---|
| Reporter: | Jared S (Silver Quality Contributor) | Email Updates: | |
| Status: | Not a Bug | Impact on me: | |
| Category: | Connector / ODBC | Severity: | S3 (Non-critical) |
| Version: | 5.1.5 | OS: | Windows (Any) |
| Assigned to: | CPU Architecture: | Any | |
| Tags: | connector, NET, ODBC, qc, system.byte, ToString | ||
[2 Nov 2009 11:41]
Tonci Grgin
Hi Jared and thanks for your report. I see no question nor anything remotely resembling a bug here. Please read server documentation regarding MD5 and c/ODBC documentation regarding connect option "Always handle binary function result as character data". After reading this carefully, if you still feel there's a bug here, please reopen the report and point it out to me. I'll be monitoring.
[2 Nov 2009 21:54]
Jared S
NET Flag Examples option : Respect Binary Flags=false constring: "SERVER=localhost;UID=root;password=;DATABASE=mysql;PORT=3306;Respect Binary Flags=false" documents: http://dev.mysql.com/doc/refman/5.0/en/connector-net-programming-connection-options.html ODBC Falg Example option : OPTION=268435456 constring: "DRIVER={MySQL ODBC 5.1 Driver}; SERVER=localhost; UID=root; DATABASE=mysql; PORT=3306;OPTION=268435456" documents: http://dev.mysql.com/doc/refman/5.0/en/connector-odbc-configuration-connection-parameters.... SQL Example SELECT CONVERT(MD5('abc123')USING latin1)
Portions of this website are copyright © 2001, 2002 The PHP Group
Page generated in 0.051 sec. using MySQL 8.4.7-u6-cloud
Timestamp references displayed by the system are UTC.
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.
Description: .ToString returns System.Byte[] How to repeat: using System; using System.Windows.Forms; namespace WindowsFormsApplication1 { public partial class Form1 : Form { public System.Data.Odbc.OdbcDataReader DTR0; public System.Data.Odbc.OdbcConnection CON0; public System.Data.Odbc.OdbcCommand CMD0; public Form1() { InitializeComponent(); } private void button1_Click(object sender, EventArgs e) { CMD0 = new System.Data.Odbc.OdbcCommand("SELECT MD5('123acb')", CON0); DTR0 = CMD0.ExecuteReader(); Console.WriteLine(DTR0[0].ToString()); //BUG Outputs --> "System.Byte[]" } private void Form1_Load(object sender, EventArgs e) { CON0 = new System.Data.Odbc.OdbcConnection(); CON0.ConnectionString = "DRIVER={MySQL ODBC 5.1 Driver}; SERVER=localhost; UID=root; DATABASE=mysql; PORT=3306;"; CON0.Open(); } } } Suggested fix: 'my VB workaround, could be used as a fix Public Function OBJECT2STRING(ByVal xObject As Object) As String Dim zBytes() As Byte Dim zString As String If TypeOf xObject Is System.Byte() Then zBytes = DirectCast(xObject, System.Byte()) zString = System.Text.Encoding.Default.GetString(zBytes) Else zString = xObject.ToString End If Return zString End Function