2009-05-06 61 views
1

我有一張名爲jobs的表格,我可以從表格中獲取數據但沒有問題,但保存會導致問題。下面是代碼和錯誤:爲什麼我無法使用SubSonic保存數據庫事務?

 Job job = new Job(JobId); 

     job.Name = txtName.Text; 
     job.SimsCustCode = txtSimsCustCode.Text; 
     job.Mode = cboMode.Text; 
     job.Interval = Convert.ToInt32(nudInterval.Text); 
     job.Enabled = Convert.ToBoolean(chkEnabled.Checked); 

     job.SourceHost = txtSourceHostName.Text; 
     job.SourceType = cboSourceType.Text; 
     job.SourceUsername = txtSourceUsername.Text; 
     job.SourcePassword = txtSourcePassword.Text; 
     job.SourceDirectory = txtSourceDirectory.Text; 
     job.SourceIgnoreExtension = txtSourceIgnoreExtension.Text; 

     job.TargetHost = txtTargetHostName.Text; 
     job.TargetType = cboTargetType.Text; 
     job.TargetUsername = txtTargetUsername.Text; 
     job.TargetPassword = txtTargetPassword.Text; 
     job.TargetDirectory = txtTargetDirectory.Text; 
     job.TargetTempExtension = txtTargetTempExtension.Text; 

     job.Save(); 

以下是錯誤:

A first chance exception of type 'MySql.Data.MySqlClient.MySqlException' occurred in MySql.Data.dll 
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 'interval) VALUES('adf','adsf','inbound','ftp','','','','','','ftp','','','','','' at line 1 

爲了澄清,如果我編輯現有的工作它工作得很好,它的唯一可取失敗新的就業機會。

這裏是架構:

表創建表


工作CREATE TABLE jobs
id INT(11)NOT NULL的auto_increment,
name VARCHAR(100)NOT NULL,
(10)NOT NULL,
mode VARCHAR(10)NOT NULL,
source_type VARCHAR(10)NOT NULL,
source_host VARCHAR(100)默認NULL,
source_username VARCHAR(50)默認NULL,
source_password VARCHAR(50)默認NULL,
source_directory VARCHAR(100)默認NULL,
source_ignore_extension VARCHAR(10)默認NULL,
target_type VARCHAR(10)NOT NULL,
target_host VARCHAR(100)默認NULL,
target_username VARCHAR(50)默認NULL,
target_password VARCHAR(50)默認NULL,
target_directory VARCHAR(100)默認NULL,
target_temp_extension VARCHAR(10)默認NULL,
enabled TINYINT(1)NOT NULL,
interval INT(11)NOT NULL,
PRIMARY KEY(id
)ENGINE = InnoDB的AUTO_INCREMENT = 7默認字符集= LATIN1

回答

1

它看起來像一值沒有被正確解析 - 我需要查看SQL模式以及正在生成的SQL - 你有探查器嗎?是什麼讓你看到發生了什麼?

區間是一個MySQL保留字:) - 你能輸入一個錯誤嗎?我們應該趕上...

+0

沒有探查器,你推薦我用什麼? – 2009-05-06 18:59:02

+0

如果你高於版本5.0.37,你可以使用這個: http://dev.mysql.com/tech-resources/articles/using-new-query-profiler.html 從你的模式我猜啓用或間隔有一個無效值。 – 2009-05-06 19:40:51

+0

亞當,這就是我想的,但它工作正常,如果我更新和現有的記錄,只是不添加一個新的。 – 2009-05-06 23:11:08

相關問題