Quantcast
Channel: MySQL Forums - Connector/NET and C#, Mono, .Net
Viewing all articles
Browse latest Browse all 1451

Reading from the stream has failed (4 replies)

$
0
0
Hello,

I am reading the results from a select statement and fairly quickly I get this exception.

Precautions I have taken:

All data is in UTF8_general_ci
Connection character set is UTF8_general_ci
Database server Character set is UTF8_general_ci.

The error occurs at the same result every time.
If I change something to the collation the exception occurs at another result.

Server : 5.5.28
.Net Connector 6.6.5

Running the same select in MySql workbench 5.2.44CE returns all results.

Exception trace:

- $exception {"Fatal error encountered during data read."} System.Exception {MySql.Data.MySqlClient.MySqlException}
+ [MySql.Data.MySqlClient.MySqlException] {"Fatal error encountered during data read."} MySql.Data.MySqlClient.MySqlException
+ Data {System.Collections.ListDictionaryInternal} System.Collections.IDictionary {System.Collections.ListDictionaryInternal}
HelpLink null string
HResult -2147467259 int
- InnerException {"Reading from the stream has failed."} System.Exception {MySql.Data.MySqlClient.MySqlException}
+ [MySql.Data.MySqlClient.MySqlException] {"Reading from the stream has failed."} MySql.Data.MySqlClient.MySqlException
+ Data {System.Collections.ListDictionaryInternal} System.Collections.IDictionary {System.Collections.ListDictionaryInternal}
HelpLink null string
HResult -2147467259 int
- InnerException {"Poging voorbij het einde van de stroom te lezen."} System.Exception {System.IO.EndOfStreamException}
+ [System.IO.EndOfStreamException] {"Poging voorbij het einde van de stroom te lezen."} System.IO.EndOfStreamException
+ Data {System.Collections.ListDictionaryInternal} System.Collections.IDictionary {System.Collections.ListDictionaryInternal}
HelpLink null string
HResult -2147024858 int
+ InnerException null System.Exception
Message "Poging voorbij het einde van de stroom te lezen." string
Source "MySql.Data" string
StackTrace " bij MySql.Data.MySqlClient.MySqlStream.ReadFully(Stream stream, Byte[] buffer, Int32 offset, Int32 count)\r\n bij MySql.Data.MySqlClient.MySqlStream.LoadPacket()" string
+ TargetSite {Void ReadFully(System.IO.Stream, Byte[], Int32, Int32)} System.Reflection.MethodBase {System.Reflection.RuntimeMethodInfo}
+ Static members
+ Non-Public members
Message "Reading from the stream has failed." string
Source "MySql.Data" string
StackTrace " bij MySql.Data.MySqlClient.MySqlStream.LoadPacket()\r\n bij MySql.Data.MySqlClient.MySqlStream.ReadPacket()\r\n bij MySql.Data.MySqlClient.NativeDriver.FetchDataRow(Int32 statementId, Int32 columns)\r\n bij MySql.Data.MySqlClient.Driver.FetchDataRow(Int32 statementId, Int32 columns)\r\n bij MySql.Data.MySqlClient.ResultSet.GetNextRow()\r\n bij MySql.Data.MySqlClient.ResultSet.NextRow(CommandBehavior behavior)\r\n bij MySql.Data.MySqlClient.MySqlDataReader.Read()" string
+ TargetSite {Void LoadPacket()} System.Reflection.MethodBase {System.Reflection.RuntimeMethodInfo}
+ Static members
+ Non-Public members
Message "Fatal error encountered during data read." string
Source "MySql.Data" string
StackTrace " bij MySql.Data.MySqlClient.MySqlDataReader.Read()\r\n bij Videotheek.Interresting.Interresting_Shown(Object sender, EventArgs e) in c:\\Users\\Lambert\\Documents\\Visual Studio 2012\\Projects\\Videotheek\\Interresting.cs:regel 81\r\n bij System.Windows.Forms.Form.OnShown(EventArgs e)\r\n bij System.Windows.Forms.Form.CallShownEvent()\r\n bij System.Windows.Forms.Control.InvokeMarshaledCallbackDo(ThreadMethodEntry tme)\r\n bij System.Windows.Forms.Control.InvokeMarshaledCallbackHelper(Object obj)\r\n bij System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)\r\n bij System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)\r\n bij System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)\r\n bij System.Windows.Forms.Control.InvokeMarshaledCallback(ThreadMethodEntry tme)\r\n bij System.Windows.Forms.Control.InvokeMarshaledCallbacks()\r\n bij System.Windows.Forms.Control.WndProc(Message& m)\r\n bij System.Windows.Forms.ScrollableControl.WndProc(Message& m)\r\n bij System.Windows.Forms.ContainerControl.WndProc(Message& m)\r\n bij System.Windows.Forms.Form.WndProc(Message& m)\r\n bij System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m)\r\n bij System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m)\r\n bij System.Windows.Forms.NativeWindow.DebuggableCallback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)\r\n bij System.Windows.Forms.UnsafeNativeMethods.DispatchMessageW(MSG& msg)\r\n bij System.Windows.Forms.Application.ComponentManager.System.Windows.Forms.UnsafeNativeMethods.IMsoComponentManager.FPushMessageLoop(IntPtr dwComponentID, Int32 reason, Int32 pvLoopData)\r\n bij System.Windows.Forms.Application.ThreadContext.RunMessageLoopInner(Int32 reason, ApplicationContext context)\r\n bij System.Windows.Forms.Application.ThreadContext.RunMessageLoop(Int32 reason, ApplicationContext context)\r\n bij System.Windows.Forms.Application.RunDialog(Form form)\r\n bij System.Windows.Forms.Form.ShowDialog(IWin32Window owner)\r\n bij System.Windows.Forms.Form.ShowDialog()\r\n bij Videotheek.Form1.radioButton1_CheckedChanged_1(Object sender, EventArgs e) in c:\\Users\\Lambert\\Documents\\Visual Studio 2012\\Projects\\Videotheek\\Form1.cs:regel 274\r\n bij System.Windows.Forms.RadioButton.OnCheckedChanged(EventArgs e)\r\n bij System.Windows.Forms.RadioButton.set_Checked(Boolean value)\r\n bij System.Windows.Forms.RadioButton.OnClick(EventArgs e)\r\n bij System.Windows.Forms.RadioButton.OnMouseUp(MouseEventArgs mevent)\r\n bij System.Windows.Forms.Control.WmMouseUp(Message& m, MouseButtons button, Int32 clicks)\r\n bij System.Windows.Forms.Control.WndProc(Message& m)\r\n bij System.Windows.Forms.ButtonBase.WndProc(Message& m)\r\n bij System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m)\r\n bij System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m)\r\n bij System.Windows.Forms.NativeWindow.DebuggableCallback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)\r\n bij System.Windows.Forms.UnsafeNativeMethods.DispatchMessageW(MSG& msg)\r\n bij System.Windows.Forms.Application.ComponentManager.System.Windows.Forms.UnsafeNativeMethods.IMsoComponentManager.FPushMessageLoop(IntPtr dwComponentID, Int32 reason, Int32 pvLoopData)\r\n bij System.Windows.Forms.Application.ThreadContext.RunMessageLoopInner(Int32 reason, ApplicationContext context)\r\n bij System.Windows.Forms.Application.ThreadContext.RunMessageLoop(Int32 reason, ApplicationContext context)\r\n bij System.Windows.Forms.Application.Run(Form mainForm)\r\n bij Videotheek.Program.Main() in c:\\Users\\Lambert\\Documents\\Visual Studio 2012\\Projects\\Videotheek\\Program.cs:regel 19" string
+ TargetSite {Boolean Read()} System.Reflection.MethodBase {System.Reflection.RuntimeMethodInfo}
+ Static members
+ Non-Public members
+ this {Videotheek.Interresting, Text: Interresting} Videotheek.Interresting
+ sender {Videotheek.Interresting, Text: Interresting} object {Videotheek.Interresting}
+ e {System.EventArgs} System.EventArgs
bFirst false bool
nOld 0 int
IdActor 0 int
Age 0 int
Gender 0 int
Year 0 int
nRef 1 int
t1 null string


Database Create Statements:
CREATE TABLE `tempresults` (
`MovieId` int(11) NOT NULL,
`IdActor` int(11) NOT NULL,
`age` int(11) NOT NULL DEFAULT '0',
`dob` date NOT NULL DEFAULT '1900-01-01',
`Year` year(4) NOT NULL DEFAULT '1901',
`Gender` int(1) NOT NULL DEFAULT '0',
PRIMARY KEY (`MovieId`,`IdActor`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8

CREATE TABLE `refmovie` (
`MovieId` int(11) NOT NULL,
`MovieName` varchar(200) NOT NULL,
`Description` longtext,
`Year` year(4) DEFAULT NULL,
`Link` varchar(100) NOT NULL,
`Completed` bit(1) NOT NULL,
PRIMARY KEY (`MovieId`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8

CREATE TABLE `actor` (
`IdActor` int(11) NOT NULL,
`NameActor` varchar(120) NOT NULL,
`dob` date DEFAULT NULL,
`alive` bit(1) DEFAULT NULL,
`Gender` bit(1) DEFAULT NULL,
`LifeStory` longtext,
`Completed` bit(1) DEFAULT NULL,
`dod` date DEFAULT NULL,
`Link` varchar(50) DEFAULT NULL,
PRIMARY KEY (`IdActor`),
KEY `Name` (`NameActor`) USING HASH,
KEY `Link` (`Link`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8

CREATE TABLE `actorbyrefmovie` (
`idActor` int(11) NOT NULL,
`MovieId` int(11) NOT NULL,
`Act` longtext,
PRIMARY KEY (`idActor`,`MovieId`),
KEY `IdActor` (`idActor`) USING HASH,
KEY `IdMovie` (`MovieId`) USING HASH
) ENGINE=InnoDB DEFAULT CHARSET=utf8

Piece of code:

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using MySql.Data.MySqlClient;
using System.Threading;
using System.Windows.Forms;

namespace Videotheek
{
public partial class Interresting : Form
{
public bool bRebuild = false;
MySqlConnection conn = new MySqlConnection(Form1.sqlconnect);
MySqlConnection conn1 = new MySqlConnection(Form1.sqlconnect);
MySqlCommand cmd1 = new MySqlCommand();
MySqlCommand cmd = new MySqlCommand();
MySqlDataReader s,s1;
int LastIdActor = 0;
int MovieId = 0;
int nCount = 0;
int nYoung = 0;
int nAll = 0;
int nUn = 0;
int nYear = 0;
public Interresting()
{
InitializeComponent();
conn.Open();
cmd.Connection = conn;
cmd.CommandTimeout = 0;
cmd.CommandText = "set net_write_timeout=" + Timeout.Infinite + "; set net_read_timeout=" + Timeout.Infinite + "; Set Character_Set_Connection='UTF8'; set Collation_connection='utf8_general_ci';";
cmd.ExecuteNonQuery();
conn1.Open();
cmd1.Connection = conn1;
cmd1.CommandTimeout = 0;
cmd1.CommandText = "set net_write_timeout=" + Timeout.Infinite + "; set net_read_timeout=" + Timeout.Infinite + "; Set Character_Set_connection='UTF8'; set collation_connection='utf8_general_ci';";
cmd1.ExecuteNonQuery();
}

private void Interresting_Shown(object sender, EventArgs e)
{
cmd.CommandText = "Lock table Actor read;";
cmd.ExecuteNonQuery();
cmd.CommandText = "Select IdActor from Actor order by IdActor desc limit 1;";
s = cmd.ExecuteReader();
s.Read();
LastIdActor = Convert.ToInt32(s[0].ToString());
s.Close();
int IdActor;
int Age=0;
int Gender;
int Year;
cmd.CommandText = "Unlock tables;";
cmd.ExecuteNonQuery();
int nRef = 1;
string t1;
if (bRebuild)
{
/* try
{
cmd.CommandText = "drop table tempresults;";
cmd.ExecuteNonQuery();
}
catch
{
}
*/ cmd.CommandText="SET sql_mode='NO_UNSIGNED_SUBTRACTION';";
cmd.ExecuteNonQuery();
cmd.CommandText = "delete from tempresults;";
cmd.ExecuteNonQuery();
cmd.CommandText = "Unlock tables;";
cmd.ExecuteNonQuery();
cmd1.CommandText = "Lock table tempresults write;";
cmd1.ExecuteNonQuery();
cmd.CommandText = "Select ActorByRefMovie.MovieId, ActorByRefMovie.IdActor, Refmovie.Year-Year(Actor.dob) as `age`,Actor.dob as `dob`,RefMovie.Year as `Year`,ACtor.Gender as `Gender` from ActorByRefMovie inner join Actor on ActorByRefmovie.IDactor=Actor.IdActor inner join RefMovie on Actorbyrefmovie.MovieId=refmovie.MovieId;";
s = cmd.ExecuteReader();
while (s.Read())
{
cmd1.CommandText = "Insert into Tempresults (MovieId, Idactor,age,dob,Year,Gender) values(" + Convert.ToInt32(s[0].ToString()).ToString() + "," + Convert.ToInt32(s[1].ToString()).ToString() + "," +
Convert.ToInt32(s[2].ToString()).ToString() + ",'" + HtmlDecode.ConvertDate(s[3].ToString()) + "'," + Convert.ToInt32(s[4].ToString()).ToString() + "," + Convert.ToInt32(s[5].ToString()).ToString() + ");";
cmd1.ExecuteNonQuery(); // errror occurs here after 1480 records read out of roughly 6M(illion) records.
}
s.Close();
cmd1.CommandText = "Unlock tables;";
cmd1.ExecuteNonQuery();

Has anybody got a clue why I get this exception?
Workbench finishes ok.

Thanks for any help
Lambert

Viewing all articles
Browse latest Browse all 1451

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>