我正在尝试向我正在构建的网站添加评论。由于审查的内容被分成 3 个表,我试图在数据库中执行 3 次插入以进行一次审查。该页面在我运行它时显示,所以我知道它大部分都在工作,但是当我单击提交按钮时,我得到一个:
Syntax error (missing operator) in query expression '3')'' error message.
据说问题出在这行代码中:
Line 86: dbInsert.ExecuteNonQuery()
这是我在本节中的代码:
Dim sql As String = "INSERT INTO MovieReviews (MovieID, MReviewID, ReviewerType, ReviewDate, UserID) "
sql = sql & " VALUES ('" & movID & "','" & review_id & "','" & 2 & "','" & Date.Now & "'," & uID & "')'"
Dim sql2 As String = "INSERT INTO MReviewRatings (MReviewID, ValueForMoney, ActingAbility, SpecialEffects, Plot, Total) "
sql2 = sql2 & " VALUES ('" & movID & "','" & moneyStar(moneyStarRating) & "','" & actingStar(actingStarRating) & "','" & effectsStar(effectStarRating) & "','" & plotStar(plotStarRating) & "','" & totalStar(avg) & "')'"
Dim sql3 As String = "INSERT INTO MReviewTexts (MReviewID, ReviewText) "
sql3 = sql3 & " VALUES ('" & review_id & "','" & txtReviewText.Text & "')'"
dbInsert.CommandText = sql
dbInsert.CommandType = CommandType.Text
dbInsert.Connection = aConnection
dbInsert2.CommandText = sql2
dbInsert2.CommandType = CommandType.Text
dbInsert2.Connection = aConnection
dbInsert3.CommandText = sql3
dbInsert3.CommandType = CommandType.Text
dbInsert3.Connection = aConnection
dbInsert.ExecuteNonQuery()
dbInsert2.ExecuteNonQuery()
dbInsert3.ExecuteNonQuery()
我不确定是什么导致了这个问题。有谁知道我如何才能将评论插入数据库?