Skip navigation links

MySQL Forums :: C#, Mono, .Net :: Using ExecuteNonQuery() Invalid attempt to access a field before calling Read()


Advanced Search

Using ExecuteNonQuery() Invalid attempt to access a field before calling Read()
Posted by: Mathieu Bewers ()
Date: February 25, 2010 11:59AM

Hello

I know this error has been posted many times before, but I am struggling to understand why it is happening when I am using the ExecuteNonQuery() method from the MySqlCommand library with an INSERT query which, I know, is the right method to use for an INSERT query.

When I run the procedure in my code, no output appears and no record is inserted into the database.

I have double-checked my stored procedure within my database and in my code.
The procedure which is being used is as follows (sorry if it seems long)

DELIMITER $$

DROP PROCEDURE IF EXISTS `sp_importPaper` $$
CREATE DEFINER=`mb326`@`138.38.%` PROCEDURE `sp_importPaper`(
IN `@file` varchar(45),
IN `@dBaseID` varchar(45),
IN `@author1FirstName` varchar(45),
IN `@author1Surname` varchar(45),
IN `@author1email` varchar(45),
IN `@author1Institution` varchar(45),
IN `@author2FirstName` varchar(45),
IN `@author2Surname` varchar(45),
IN `@author2email` varchar(45),
IN `@author2Institution` varchar(45),
IN `@author3FirstName` varchar(45),
IN `@author3Surname` varchar(45),
IN `@author3email` varchar(45),
IN `@author3Institution` varchar(45),
IN `@journal` varchar(100),
IN `@volume` int,
IN `@issue` int,
IN `@totalPages` int,
IN `@DOI` varchar(45),
IN `@paperType` varchar(45),
IN `@importDate` datetime,
IN `@keyItem` varchar(200),
IN `@note` varchar(2000))
BEGIN
INSERT INTO PROJmb326.Paper(title, dBaseID, Author1FirstName,
Author1Surname, Author1email, Author1Institution, Author2FirstName,
Author2Surname, Author2email, Author2Institution, Author2FirstName,
Author2Surname, Author2email, Author2Institution, Journal, volume,
issue, totalPages, DOI, paperType, importDate, keyItem, note)
VALUES (`@title`,`@dBaseID`, `@author1FirstName`,
`@author1Surname`, `@author1email`, `@author1Institution`,
`@author2FirstName`,`@author2Surname`,
`@author2email`, `@author2Institution`,`@author3FirstName`,`@author3Surname`,
`@author3email`, `@author3Institution`,`@journal`, `@volume`, `@issue`,
`@totalPages`,`@DOI`, `@paperType`, `@importDate`, `@keyItem`, `@note`);
END $$

DELIMITER ;

Options: ReplyQuote


Subject Written By Posted
Using ExecuteNonQuery() Invalid attempt to access a field before calling Read() Mathieu Bewers 02/25/2010 11:59AM


Sorry, you can't reply to this topic. It has been closed.