问题描述
在添加记录时程序提示“添加失败”,用debug跟了代码发现在向MySQL插入数据时出的错。后来打开mysql,单独执行该语句仍然出错。以下是具体情况:sql语句是:Insert INTO testTbl (ID) Values (586)表结构是:mysql> desc testTbl;+------------------+---------------+------+-----+---------+-------+| Field | Type | Null | Key | Default | Extra |+------------------+---------------+------+-----+---------+-------+| ID | int(10) | NO | | 0 | || Comp_Totalsect | varchar(10) | YES | | NULL | || Comp_Sort | varchar(20) | YES | | NULL | || Comp_Category | varchar(40) | YES | | NULL | || Comp_Content | varchar(8) | YES | | NULL | || Comp_Vol | int(10) | YES | | NULL | || ArchNo | varchar(80) | YES | | NULL | || Archive_Name | varchar(400) | YES | | NULL | || Secret_Level | varchar(10) | YES | | NULL | || Storage_Life | varchar(10) | YES | | NULL | || FileYear | smallint(4) | YES | | NULL | || Archive_Unit | varchar(50) | YES | | NULL | || Storage_Unit | varchar(50) | YES | | NULL | || LeiMu | varchar(20) | YES | | NULL | || Keywords | varchar(255) | YES | | NULL | || Importer | varchar(20) | YES | | NULL | || CreateDate | datetime | YES | | NULL | || CheckMan | varchar(20) | YES | | NULL | || Hua_Kong | varchar(10) | YES | | NULL | || Page_Num | int(10) | YES | | NULL | || Register_Unit | varchar(50) | YES | | NULL | || Can_Brrw | int(5) | NO | | 1 | || Can_BrrwCopies | int(5) | YES | | 1 | || CanCopies | int(5) | YES | | 1 | || StatusBT | smallint(2) | YES | | 0 | || HandOverStatus | smallint(1) | YES | | 0 | || Del_Tag | smallint(1) | YES | | 0 | || FullTextFile | int(10) | YES | | NULL | || FileNo | int(10) | YES | | NULL | || WenHao | varchar(2000) | YES | | NULL | || File_Date | datetime | YES | | NULL | || Principal | varchar(2000) | YES | | NULL | || Total_Vol | int(10) | YES | | NULL | || Memo | varchar(2000) | YES | | NULL | || AboutInfo | varchar(3000) | YES | | NULL | || Old_Organization | varchar(1000) | YES | | NULL | || Judge | varchar(500) | YES | | NULL | || EndYear | varchar(20) | YES | | NULL | || Old_ArchNo | varchar(200) | YES | | NULL | || Old_Comp_Content | varchar(200) | YES | | NULL | || Old_Comp_Sort | varchar(200) | YES | | NULL | || Old_Comp_Vol | varchar(200) | YES | | NULL | || KeepYear | smallint(4) | YES | | 1000 | |+------------------+---------------+------+-----+---------+-------+43 rows in set (0.02 sec)mysql> Insert INTO testTbl (ID) Values (586);ERROR 1054 (42S22): Unknown column 'FileNo' in 'field list'这就奇怪了,我只插入一个id而已,怎么会说到FileNo,而且表里面也有那一列啊,反复看就是发现不了错误,发上来看各位能否看出一些端倪,在此谢过~
解决方案
mysql的bug 看看这个http://bugs.mysql.com/bug.php?id=1689
解决方案二:
在表名testTbl 前面加上数据库名字.多测几次看有什么提示?