我想通過MySql/.NEt連接器使用.Net執行INSERT INTO查詢。該查詢使用參數。這是相當簡單:MySql表示列不能爲null! [使用命名參數]
INSERT INTO post (
ID, content, post_url, blogID, title, addedOn,
updatedDate, commentsFeedURL, active, viewCount,
commentCount, languageID, authorName, postDate,
posRating, negRating, adult)
VALUES(
@ID, @content, @post_url, @blogID, @title, @addedOn,
@updatedDate, @commentsFeedURL, @active, @viewCount,
@commentCount, @languageID, @authorName, @postDate,
@posRating, @negRating, @adult)
當我運行它(與正式分配的所有參數),我得到一個錯誤
「列POST_URL「不能爲空」
但它不是空。這是在參數POST_URL
的價值,這是我使用的參數分配給SQL查詢的代碼
cmd.Parameters.AddWithValue("post_url", postOld.URL);
可能是什麼,我得到這個的原因行爲?
你可以嘗試打印出真實的查詢字符串嗎? –
是的,實際的查詢字符串是帖子的一部分。以'INSERT INTO'開頭的位。嘗試滾動它。 –
也,你爲什麼不把你的字符串參數放在引號中? –