Integrity constraint violation: 1062 Duplicate entry


I just set up a the Spreadsheet plugin in a Drupal server, and I get this error when attempting to create a spreadsheet:

PDOException: SQLSTATE[23000]: Integrity constraint violation: 1062 Duplicate entry ‘demo_sheet’ for key ‘PRIMARY’: INSERT INTO mldl_dhx_sheet VALUES (‘demo_sheet’, null, null, ‘any_key’, null); Array ( ) in sh_load_dump() (line 72 of /QA/sites/all/modules/spreadsheet/spreadsheet.php).

Table mldl_dhx_sheet currently has one entry

| sheetid | userid | name | key | cfg |
| demo_sheet | NULL | NULL | any_key | NULL |

I’m not sure how to get around this.

please, open file wp-content/plugins/dhtmlxspreadsheet/spreadsheet.php and comment all calls of method sh_load_dump:



Thank You radyno, that worked out.

The error is gone but now the spreadsheet is not visible. I followed the other threads regarding this issue and I cant seem to track down the issue with my example.

I dont get any JS errors on the page. and here is the code which is spat out by Drupal:

<p>You can insert any text before

<script src='' type='text/javascript' charset='utf-8'></script>
<link rel='stylesheet' href='' type='text/css' charset='utf-8'>
<link rel='stylesheet' href='' type='text/css' charset='utf-8'>
<link rel='stylesheet' href='' type='text/css' charset='utf-8'>

<script type='text/javascript'>var dhx_sh;
function onload_func_971150() {
	window.setTimeout(function() {
		var cfg = {
	sheet: '1',
	dhx_rel_path: '',
	parent: 'spreadsheet_box_971150',
	load: '',
	save: '',
skin: 'dhx_skyblue',
math: false,
autowidth: false,
autoheight: true

dhx_sh = new dhtmlxSpreadSheet({
			load: cfg.load,
			parent: cfg.parent,
			autowidth: cfg.autowidth,
			autoheight: cfg.autoheight,
			math: cfg.math,
			icons_path: cfg['dhx_rel_path'] + 'imgs/icons/',
			image_path: cfg['dhx_rel_path'] + 'imgs/'
		dhx_sh.load(cfg.sheet||'1', cfg.key||null);
	}, 1);
dhtmlxEvent(window, 'load', onload_func_971150);</script><div id='spreadsheet_box_971150' style='width: 100%; height: auto; background-color:white;'></div>

or after spreadsheet instance</p>

I can manually bring up the spreadsheet by calling : dhx_sh.init()
from the command line but that isn’t really a solution (it also throws a ton of errors if i do call init and start clicking around the spreadsheet). Here is the error just in case: Uncaught TypeError: Cannot read property 'setItemState' of undefined spreadsheet.php?load=js:10441
Here is the line too: if (this.objPull[itemId][name] != null)

Without the manual init; there are absolutely no errors appearing.

could you provide link to your page with spreadsheet?


Here is a link to a test page.

The code Im running on here is just the simple example:

You can insert any text before
or after spreadsheet instance