| Bug #6323 | MySqlDataReader.GetBytes + .getChars throws Exception | ||
|---|---|---|---|
| Submitted: | 29 Oct 2004 15:14 | Modified: | 9 Nov 2004 22:26 | 
| Reporter: | Jochen Hamleh | Email Updates: | |
| Status: | Can't repeat | Impact on me: | |
| Category: | Connector / NET | Severity: | S1 (Critical) | 
| Version: | 1.0.1.12619 | OS: | Windows (Windows 2000) | 
| Assigned to: | Reggie Burnett | CPU Architecture: | Any | 
   [9 Nov 2004 22:26]
   Reggie Burnett        
  Not enough information was provided for us to be able to handle this bug. Please re-read the instructions at http://bugs.mysql.com/how-to-report.php If you can provide more information, feel free to add it to this bug and change the status back to 'Open'. Thank you for your interest in MySQL. Additional info: I am unable to repeat this behavior. If you want to send me a small application that shows this behavior, I will be happy to look at it again.
   [10 Nov 2004 11:21]
   Jochen Hamleh        
  Hi Reggie, I found an easy solution for this problem. The problem only occured when the ExecuteReader-Method of the MySqlCommand-Class is called with parameter CommandBehavior.SequentialAccess. Without parameters the method works fine. Is there probably a problem with the SequentialAccess-Behavior of the ExecuteReader-Method ? You can set the status of this bug to closed. (Now I have another problem with the bug #6322 ...) Best regards, Jochen


Description: Hi Reggie, there seems to be a problem in the methods GetBytes and GetChars in the MySqlDataReader-Class that not occured in version 1.0.0.22722. Both methods always throwing an exception "System.ArgumentOutOfRangeException: Nicht-negative Zahl erforderlich; Parametername: count" at System.IO.BufferedStreamRead(Byte[] array, Int32 offset, Int32 count). "Nicht-negative Zahl erforderlich" is german (I'm using a german .NET-Framework, because I am a german ;-) ) that means in english something like "no-negative number needed". Could you help me ? (Please excuse my bad english !) Best regards, Jochen Hamleh How to repeat: This is a function in VB.NET I use to write a file, that is saved in a MySQL 4.1.4_gamma database, to a given directory (= ziel). "OeffneVerbindung() gives me a valid Connection back in con. Try-Catch always runs to Catch at daten.GetBytes or daten.GetChars. This function had no problems with version 1.0.0.22722. Public Shared Function HoleBlob(ByVal tabelle As String, ByVal blobfeld As String, _ ByVal zeilenID As String, ByVal ziel As String) As Boolean Dim rueckgabe As Boolean = True Dim con As MySqlConnection = OeffneVerbindung() Dim sqlSelect As MySqlCommand Dim daten As MySqlDataReader Dim blob(9999) As Byte Dim sql As String = "select " & blobfeld & " " & _ "from " & tabelle & " " & _ "where " & zeilenID Try sqlSelect = New MySqlCommand(sql, con) daten = sqlSelect.ExecuteReader(CommandBehavior.SequentialAccess) If daten.Read() Then File.Delete(ziel) Dim fs As New FileStream(ziel, FileMode.OpenOrCreate, FileAccess.Write) Dim bw As New BinaryWriter(fs) Dim bufferSize As Integer = 10000 'Dim outbyte(bufferSize - 1) As Byte Dim outbyte(bufferSize - 1) As Char Dim retval As Long Dim startIndex As Long = 0 'retval = daten.GetBytes(0, startIndex, outbyte, 0, bufferSize) retval = daten.GetChars(0, startIndex, outbyte, 0, bufferSize) While retval = bufferSize bw.Write(outbyte) bw.Flush() startIndex = startIndex + bufferSize 'retval = daten.GetBytes(0, startIndex, outbyte, 0, bufferSize) retval = daten.GetChars(0, startIndex, outbyte, 0, bufferSize) End While bw.Write(outbyte, 0, retval) bw.Flush() bw.Close() fs.Close() rueckgabe = True Else rueckgabe = False End If Catch ex As Exception rueckgabe = False Finally If Not daten Is Nothing Then daten.Close() End If If Not sqlSelect Is Nothing Then sqlSelect.Dispose() End If con.Close() con.Dispose() End Try Return rueckgabe