Page 1 of 1

ExectureNonQuery gets schema?

Posted: Sun 31 Dec 2006 18:19
by ianb
I am doing an insert using ExecuteNonQuery on a table that has a structure like
id bigint(20) NOT NULL, name varchar(45)

There is an insert trigger that sets id if not supplied. An insert such as INSERT test (name) values(@val) works ok in mysqlbrowser but fails when calling executeNonQuery with an error 'Field 'id' doesnt have a default value'. My question is, is the provider doing something that mysqlbrowser isn't in order to cause this error?

Thanks
Ian

Posted: Tue 02 Jan 2007 12:31
by Alexey
Please provide me with your trigger definition.

Posted: Tue 02 Jan 2007 21:21
by ianb
Here's the table definition and sample query:

INSERT INTO testtbl SET name = 'cxcc';


SET NAMES utf8;

SET SQL_MODE='';
SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='NO_AUTO_VALUE_ON_ZERO';

/*Table structure for table `testtbl` */

CREATE TABLE `testtbl` (
`id` bigint(20) NOT NULL,
`name` varchar(14) default NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;


/*Trigger structure for table `testtbl` */

DELIMITER $$

DROP TRIGGER `ins`$$

CREATE TRIGGER `ins` BEFORE INSERT ON `testtbl` FOR EACH ROW BEGIN
if NEW.id = 0 or NEW.id IS NULL THEN
SET NEW.id = COALESCE((SELECT MAX(id)+1 FROM testtbl), 1);
END IF;
END$$


DELIMITER ;

SET SQL_MODE=@OLD_SQL_MODE;

Posted: Wed 03 Jan 2007 07:28
by Alexey
What version of MySQLDirect .NET do you use? Try to use the latest one. Should work without any problem.

Posted: Wed 03 Jan 2007 15:42
by ianb
Hello,
I updated to version 3.55.18.0. Same problem.
Thanks
Ian

Posted: Fri 05 Jan 2007 16:41
by Alexey
We cannot reproduce such problem.
Please send us small test project to reproduce the problem.
Use e-mail address provided in the Readme file.
Do not use third party components.