Update语句没有错误但不起作用

时间:2014-06-01 16:40:52

标签: sql vb.net

我想更新用户的个人资料但不起作用,并且不会返回任何错误。我只是不明白它怎么能没有错误地通过代码但仍然什么都不做。

Dim connect As String = System.Configuration.ConfigurationManager.ConnectionStrings("Nstandcon").ConnectionString

    Dim cnn As New System.Data.SqlClient.SqlConnection(connect)
    Dim cmd As New Data.SqlClient.SqlCommand

    cnn.Open()

    cmd.Connection = cnn

    cmd.CommandText = "Update Profile_N SET Surname = @Surname, Names = @Names, Profile_Pic = @Profile_Pic, Status = @Status, Comment = @Comment, NOK = @NOK, Last_Login = @Last_Login, Hometown = @Hometown WHERE UserId = @UserId"



    cmd.Parameters.AddWithValue("@UserId", Idofuser)

    cmd.Parameters.AddWithValue("@Names", name.Value)
    cmd.Parameters.AddWithValue("@Surname", last.Value)
    cmd.Parameters.AddWithValue("@Profile_Pic", imgByte)
    'cmd.Parameters.AddWithValue("@Gender", Select2.Value.ToString)
    cmd.Parameters.AddWithValue("@Status", Select1.Value.ToString)
    cmd.Parameters.AddWithValue("@Comment", comen.Value)
    cmd.Parameters.AddWithValue("@NOK", NOK.Value)
    cmd.Parameters.AddWithValue("@DOB", age.Value)
    cmd.Parameters.AddWithValue("@Last_Login", Now())
    cmd.Parameters.AddWithValue("@Hometown", hometown.Value)

    'Try
    cmd.ExecuteNonQuery()

    'Catch

    'lblresults.Text = "There was an error updating your profile, try later."
    'Finally
    cnn.Close()
    '    lblresults.Text = "Your profile was updated successfully."
    'End Try

0 个答案:

没有答案