I can't insert record into mysql database (joomla CMS table jos_content). Receive: Exception:"You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use
Any idea, what could be wrong, since I'm just copying all data except autoincremental from source record (same database, same table!)
//using Subsonic 2.2 , connecting to mysql server 5.1.33-community
//just to test that reading works OK
JosContentCollection jcc = new JosContentCollection().Load();
foreach (var content in jcc)
{
Console.WriteLine(content.Id + " " + content.Title);
}
//foreach works OK... shows all records
JosContent jcSource = new JosContent(2); //use previous record as source
Console.WriteLine("Read record:"+jcSource.Id + " " + cSource.Title);
//read OK... record was found and shown!
JosContent jc= new JosContent();
//all records copied from source record except autoincremental field
//jc.Id = //auto increment field
jc.Title = "test from c# "; // +DateTime.Now.ToShortTimeString();
jc.AliasX = "test-from-c";
jc.TitleAlias = jcSource.TitleAlias; //String.Empty;
jc.Introtext = jcSource.Introtext; // "short intro text";
jc.Fulltext = jcSource.Introtext; // "long html";
jc.State = jcSource.State; // true;
jc.Sectionid = jcSource.Sectionid; // 1;
jc.Mask = jcSource.Mask; //0;
jc.Catid = jcSource.Catid;
jc.Created = jcSource.Created; // DateTime.Now;
jc.CreatedBy = jcSource.CreatedBy;
jc.CreatedByAlias = jcSource.CreatedByAlias;
jc.Modified = jcSource.Modified; // DateTime.Now;
jc.ModifiedBy = jcSource.ModifiedBy;
jc.CheckedOut = jc.CheckedOut;
jc.CheckedOutTime = jcSource.CheckedOutTime; // DateTime.Now;
jc.PublishUp = jcSource.PublishUp; // DateTime.Now;
jc.PublishDown = jcSource.PublishDown; // DateTime.Now;
jc.Images = jcSource.Images;
jc.Urls = jcSource.Url;
jc.Attribs = jcSource.Attribs;
jc.Version = jc.Version;
jc.Parentid = jc.Parentid;
jc.Ordering = jc.Ordering;
jc.Metakey = jcSource.Metakey;
jc.Metadesc = jcSource.Metadesc;
jc.Access = jcSource.Access;
jc.Hits = jcSource.Hits;
jc.Metadata = jcSource.Metadata;
jc.Save(); //Generates exception:
/*
MySql.Data.MySqlClient.MySqlException was unhandled
Message="You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'fulltext,state,sectionid,mask,catid,created,created_by,created_by_alias,modified' at line 1"
Source="MySql.Data"
ErrorCode=-2147467259
Number=1064
StackTrace:
at MySql.Data.MySqlClient.MySqlStream.OpenPacket()
at MySql.Data.MySqlClient.NativeDriver.ReadResult(UInt64& affectedRows, Int64& lastInsertId)
at MySql.Data.MySqlClient.MySqlDataReader.GetResultSet()
at MySql.Data.MySqlClient.MySqlDataReader.NextResult()
at MySql.Data.MySqlClient.MySqlCommand.ExecuteReader(CommandBehavior behavior)
at MySql.Data.MySqlClient.MySqlCommand.ExecuteReader()
at MySql.Data.MySqlClient.MySqlCommand.ExecuteScalar()
at SubSonic.MySqlDataProvider.ExecuteScalar(QueryCommand qry)
at SubSonic.DataService.ExecuteScalar(QueryCommand cmd)
at SubSonic.ActiveRecord`1.Save(String userName)
at SubSonic.ActiveRecord`1.Save()
at joomlamysqlapi.Program.VsaVsebina() in R:\joomlamysqlapi\Program.cs:line 114
at joomlamysqlapi.Program.Main(String[] args) in R:\joomlamysqlapi\Program.cs:line 13
at System.AppDomain._nExecuteAssembly(Assembly assembly, String[] args)
at Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly()
at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
at System.Threading.ThreadHelper.ThreadStart()
InnerException:
-- ----------------------------
-- Table structure for `jos_content`
-- ----------------------------
DROP TABLE IF EXISTS `jos_content`;
CREATE TABLE `jos_content` (
`id` int(11) unsigned NOT NULL AUTO_INCREMENT,
`title` varchar(255) NOT NULL DEFAULT '',
`alias` varchar(255) NOT NULL DEFAULT '',
`title_alias` varchar(255) NOT NULL DEFAULT '',
`introtext` mediumtext NOT NULL,
`fulltext` mediumtext NOT NULL,
`state` tinyint(3) NOT NULL DEFAULT '0',
`sectionid` int(11) unsigned NOT NULL DEFAULT '0',
`mask` int(11) unsigned NOT NULL DEFAULT '0',
`catid` int(11) unsigned NOT NULL DEFAULT '0',
`created` datetime NOT NULL DEFAULT '0000-00-00 00:00:00',
`created_by` int(11) unsigned NOT NULL DEFAULT '0',
`created_by_alias` varchar(255) NOT NULL DEFAULT '',
`modified` datetime NOT NULL DEFAULT '0000-00-00 00:00:00',
`modified_by` int(11) unsigned NOT NULL DEFAULT '0',
`checked_out` int(11) unsigned NOT NULL DEFAULT '0',
`checked_out_time` datetime NOT NULL DEFAULT '0000-00-00 00:00:00',
`publish_up` datetime NOT NULL DEFAULT '0000-00-00 00:00:00',
`publish_down` datetime NOT NULL DEFAULT '0000-00-00 00:00:00',
`images` text NOT NULL,
`urls` text NOT NULL,
`attribs` text NOT NULL,
`version` int(11) unsigned NOT NULL DEFAULT '1',
`parentid` int(11) unsigned NOT NULL DEFAULT '0',
`ordering` int(11) NOT NULL DEFAULT '0',
`metakey` text NOT NULL,
`metadesc` text NOT NULL,
`access` int(11) unsigned NOT NULL DEFAULT '0',
`hits` int(11) unsigned NOT NULL DEFAULT '0',
`metadata` text NOT NULL,
PRIMARY KEY (`id`),
KEY `idx_section` (`sectionid`),
KEY `idx_access` (`access`),
KEY `idx_checkout` (`checked_out`),
KEY `idx_state` (`state`),
KEY `idx_catid` (`catid`),
KEY `idx_createdby` (`created_by`)
) ENGINE=MyISAM AUTO_INCREMENT=58 DEFAULT CHARSET=utf8;
*/