尝试在ASP.NET中更新数据库时出现“ SQL问题”

时间:2019-05-08 20:51:50

标签: asp.net vb.net webforms

我目前正在学习ASP.NET的基础知识,现在正在操作数据库。它不会转到“尝试”部分,而是直接转到Catch ex作为“异常”部分,该消息框告诉我“操作或SQL问题不成功。

    dgvResult.Visible = True
    Try
        conn.Open()
        dd.Connection = conn

        dd.CommandText = "update [STUDENT]" &
        "set [Matric]= '" & txtMatric.Text & "', " &
        "[Name] ='" & txtName.Text & "'," &
        "[Address] ='" & txtAddress.Text & "'," &
        "[Telephone] ='" & txtTelephone.Text & "'," &
        " where [Matric] ='" & txtMatric.Text & "' "

        dd.ExecuteNonQuery()
        dd.Dispose()
        conn.Close()
        MsgBox("Data Updated")



    Catch ex As Exception
        MsgBox("Unsucessful Operation or SQL Problem")
    End Try
End Sub

我的任务是在数据库中编辑一些信息并将其保存。

0 个答案:

没有答案