Fatal error encountered attempting to read the resultset.
Posted by:
David Green
Date: September 20, 2012 06:57PM
I am trying to import a CSV file into a MySQL database. I have C# code written to do the import. Thus far I have tried changing the statement to use either field or column, I have tried using \r, \n and a combination to terminate the line. I also changed the Time column from Date/Time to VARCHAR(45) and I verified that there is a table column for each column I am trying to import, unless I missed one.
This is the SQL Statement:
LOAD DATA LOCAL INFILE 'D:\\SANCentral\\Customer Files\\ibm\\70738\\0918\\Switch
Port.csv' INTO TABLE By_Switch FIELDS TERMINATED BY ',' LINES TERMINATED BY '\\\r\\n' IGNORE 1 LINES
Trying the above from the MySQL workbench doesn't work either but it doesn't say why. I am hoping I don't need to add the columns option to the statemnt, I have a lot of columns.
I am trying to execute it with this code in C# where commandstring is a string set to the above and sqlconnect is the open connection.
MySqlCommand cmd = new MySqlCommand(commandstring,sqlconnect);
cmd.ExecuteNonQuery();
this C# code worked, or at least it didn't throw an exception. The table right now is empty
commandstring = @"SELECT `CRC Error Rate` From `by_switch`";
MySqlCommand cmd = new MySqlCommand(commandstring,sqlconnect);
MySqlDataReader myReader = cmd.ExecuteReader(CommandBehavior.CloseConnection);
Here is a sample of the input, sorry about the formatting, this is all one line.
BRCOL-CORE-A,0,2000000533586F00,1,0,9/17/12 8:45 PM,304,6527.82,24454.09,30981.9013,11.34,46.27,57.602,10.27,29.19,1.778,1.937,1.904,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,1.4,5.71,3.55,0.0,0.0,0.0,0.0
B
This is the SQL that created the table:
CREATE TABLE IF NOT EXISTS `PerformanceMonitors`.`By_Switch` (
`Switch` VARCHAR(45) NOT NULL ,
`Port` VARCHAR(45) NULL ,
`WWPN` VARCHAR(45) NULL ,
`Slot` VARCHAR(45) NULL ,
`Index` VARCHAR(45) NULL ,
`Time` VARCHAR(45) NULL ,
`Interval` DOUBLE NULL ,
`Port` DOUBLE NULL ,
`Send Packet Rate` DOUBLE NULL ,
`Port Receive Packet Rate` DOUBLE NULL ,
`Total Port Packet Rate` DOUBLE NULL ,
`Port Send Data Rate` DOUBLE NULL ,
`Port Receive Data Rate` DOUBLE NULL ,
`Total Port Data Rate` DOUBLE NULL ,
`Port Peak Send Data Rate` DOUBLE NULL ,
`Port Peak Receive Data Rate` DOUBLE NULL ,
`Port Send Packet Size` DOUBLE NULL ,
`Port Receive Packet Size` DOUBLE NULL ,
`Overall Port Packet Size` DOUBLE NULL ,
`Error Frame Rate` DOUBLE NULL ,
`Dumped Frame Rate` DOUBLE NULL ,
`Link Failure Rate` DOUBLE NULL ,
`Loss of Sync Rate` DOUBLE NULL ,
`Loss of Signal Rate` DOUBLE NULL ,
`CRC Error Rate` DOUBLE NULL ,
`Short Frame Rate` DOUBLE NULL ,
`Long Frame Rate` DOUBLE NULL,
`Encoding Disparity Error Rate` DOUBLE NULL,
`Discarded Class3 Frame Rate` DOUBLE NULL,
`F-BSY Frame Rate` DOUBLE NULL,
`F-RJT Frame Rate` DOUBLE NULL,
`Port Send Bandwidth Percentage` DOUBLE NULL,
`Port Receive Bandwidth Percentage` DOUBLE NULL,
`Overall Port Bandwidth Percentage` DOUBLE NULL,
`Primitive Sequence Protocol Error Rate` DOUBLE NULL,
`Invalid Transmission Word Rate` DOUBLE NULL,
`Link Reset Transmitted Rate` DOUBLE NULL,
`Link Reset Received Rate` DOUBLE NULL,
PRIMARY KEY (`Switch`, `Time`) )