一个逗号带来的错误

sqlstr ="CREATE TABLE IF NOT EXISTS user_info";
 sqlstr+="(";
 sqlstr+="user_id INT UNSIGNED NOT NULL  PRIMARY KEY COMMENT 'Unique User ID',";
 sqlstr+="user_name VARCHAR(100) CHARACTER SET gb2312 COLLATE gb2312_chinese_ci NULL COMMENT 'Name Of User',";
 sqlstr+="user_second_sum INT UNSIGNED NOT NULL DEFAULT 0 COMMENT 'The Summation Of Using Time'";
 sqlstr+=");"; 

------------------------------------

上面是源程序的建表代码,下面是我参照上面写的,老是提示建表失败,最后发现时一个逗号惹得祸。嗨!

 'Name Of User',";
就是' 后面的那个逗号,如果最后一个字段结束后,就没有逗号了,对头!

------------------------------------
 sqlstr ="CREATE TABLE IF NOT EXISTS user_wade";
 sqlstr+="(";
 sqlstr+="ID INT UNSIGNED NOT NULL PRIMARY KEY COMMENT 'Unique User ID',";
 sqlstr+="NAME VARCHAR(100) CHARACTER SET gb2312 COLLATE gb2312_chinese_ci NULL COMMENT 'Name Of User'";
 sqlstr+=");";

posted @ 2011-05-26 10:01  贰百舞  阅读(190)  评论(0编辑  收藏  举报