.net调mysql的存储过程出错: Data too long for column '$message' at row 1
下面是我的存储过程, 主要操作论坛的表(discuz论坛), 调用时, 如果$message参数内容多, 就会提示:
Data too long for column '$message ' at row 1
把同样长度的内容, 用论坛发贴发进去, 却不会出错, 很正常!!!
message字段的类型与这里的$message参数的类型一样,都是mediumtext,即便换成text也不行.
我在.net中调用的存储过程, 用的 Mysql-Connector-Net ,问题出在哪了?
是存储过程的 bug, 还是编码的问题, 还是 Mysql-Connector-Net 问题?
CREATE PROCEDURE AddTopic($fid smallint, $author char(15), $subject char(80), $message mediumtext)
BEGIN
DECLARE $authorid mediumint;
DECLARE $postime int;
SELECT uid INTO $authorid FROM cdb_members WHERE username = $author;
SELECT MAX(dateline) INTO $postime FROM cdb_posts;
IF $postime IS NULL THEN
SET $postime = 0;
END IF;
INSERT INTO cdb_threads (fid, subject, author, authorid, dateline, lastpost) VALUES ($fid, $subject, $author, $authorid, $postime, $postime);
UPDATE cdb_forums SET threads = threads + 1 WHERE fid = $fid;
INSERT INTO cdb_posts (fid, tid, subject, author, authorid, message, dateline) VALUES ($fid, last_insert_id(), $subject, $author, $authorid, $message, $postime);
UPDATE cdb_forums SET posts = posts + 1 WHERE fid = $fid;
END;
------解决方案--------------------请参考
http://bbs.phpv.net/showthread.php?s=68ebb24afa942a2b5b16c372e57c0a19&p=45698&mode=linear
------解决方案--------------------太阳问题。
------解决方案--------------------编码问题
------解决方案--------------------你在读出的时候是什么编码,mysql设置的是什么编码,在入库的时候是什么编码,保持一致就可以了
加上这个试试 set names = 'gbk '
------解决方案--------------------set names 'gbk '
------解决方案--------------------帮顶