我有一個網站,人們互相發送消息 最近我注意到有時相同的消息發送不止一次 例如,一條消息在三秒鐘內發送四次或兩次第二個 我不明白如何發生這種情況,一旦用戶點擊發送消息的按鈕 因此,所有的窗口開關和一條消息顯示「郵件發送成功」。 我檢查過,如果用戶在發送消息後刷新頁面,那麼確實會再次發送消息。 但我不認爲是這種情況,因爲消息在一秒內發送兩次。 我正在寫在vb.net和使用mysql數據庫。 也許它與db的隊列有關,我不知道。 我需要知道去哪裏找 希望對你有所幫助插入功能被稱爲不止一次
下面的代碼:
函數調用: 呼叫GlobalFunction.update_mailbox_table(USER_ID,receiverId,txtMessage.Text,private_picture)
插入功能
Public Shared Sub update_mailbox_table(ByVal user_id As Integer, ByVal receiverId As Integer, ByVal message As String, ByVal privatePicture As Integer)
' update mailbox table
Dim connString As String = ConfigurationManager.ConnectionStrings("mysql_ConnString").ConnectionString
Using mysqlconn As New MySqlConnection(connString)
Dim sqlCommand As String = "INSERT INTO mailbox_table (FromId,Message,ToId,SendingDate,MsgStatus,PrivatePicture) VALUES (@FromId,@Message,@ToId,@SendingDate,@MsgStatus,@PrivatePicture)"
Dim mysqlcmd As New MySqlCommand(sqlCommand, mysqlconn)
Try
mysqlconn.Open()
mysqlcmd.Parameters.AddWithValue("@FromId", user_id)
mysqlcmd.Parameters.AddWithValue("@Message", message)
mysqlcmd.Parameters.AddWithValue("@ToId", receiverId)
mysqlcmd.Parameters.AddWithValue("@SendingDate", Date.Now)
mysqlcmd.Parameters.AddWithValue("@MsgStatus", 0)
mysqlcmd.Parameters.AddWithValue("@PrivatePicture", privatePicture)
mysqlcmd.ExecuteNonQuery()
Catch ex As Exception
sendToLog(ex, "problem to update mailbox table")
End Try
End Using
End Sub
沒有人接受答案,當有人給你正確的答案時,請點擊他們名字旁邊的複選標記,以便他們獲得答案的功勞,並且如果有幫助的話,也可以提供答案。 –