-1

有人可以帮我在编辑后如何检查我的数据库是否已经更新,这是我的代码..我的代码只是为了进行编辑,然后在数据库上更新它,我不知道如何检查更新是否发生..

Dim dT As DataTable = MyDB.ExecCommand("SELECT `Field Name` FROM `tblfield` ORDER BY `Field Order`", "wellsfargo").Tables(0)

            For i As Integer = 1 To flp.Controls.Count - 1
                Application.DoEvents()
                Dim xHead As uHead = DirectCast(flp.Controls(0), uHead)
                Dim xCont As uControl = DirectCast(flp.Controls(i), uControl)
                Dim sSQL As String = ""

                Dim dZ As DataTable = MyDB.ExecCommand("SELECT * FROM `" + MyJob + "` WHERE `Record Number`='" + rNum + _
                                                       "' AND `Line Number`='" + xCont.lblLine.Text.Trim.Replace("'", "\'") + "'", "wellsfargo").Tables(0)

                If dZ.Rows.Count <> 0 Then
                    sSQL = "UPDATE `" & MyJob & "` SET "
                    sSQL = sSQL + "`Orig Document Begin ID`='" + xHead.txtOrigBegDoc.Text.Trim + "'"
                    sSQL = sSQL + ",`Orig Document End ID`='" + xHead.txtOrigEndDoc.Text.Trim + "'"
                    sSQL = sSQL + ",`Beg Doc`='" + xHead.txtBegDoc.Text.Trim + "'"
                    sSQL = sSQL + ",`End Doc`='" + xHead.txtEndDoc.Text.Trim + "'"
                    sSQL = sSQL + ",`Loan Number`='" + xHead.txtLoan.Text.Trim + "'"
                    sSQL = sSQL + ",`Page Count`='" + xHead.txtPage.Text.Trim + "'"
                    sSQL = sSQL + ",`Path`='" + xHead.txtPath.Text.Trim + "'"
                    sSQL = sSQL + ",`File Number`='" + xHead.txtFileNumber.Text.Trim + "'"
                    sSQL = sSQL + ",`Settlement`='" + xHead.txtDate.Text.Trim + "'"
                    sSQL = sSQL + ",`Long and Foster`='" + xHead.txtLaF.Text.Trim + "'"
                    sSQL = sSQL + ",`Comment`='" + xHead.txtComm.Text.Trim + "'"
                    sSQL = sSQL + ",`Description`='" + xCont.cboDesc.Text.Trim.Replace("'", "\'") + "'"
                    sSQL = sSQL + ",`Amount`='" + xCont.txtAmount.Text.Trim.Replace("'", "\'") + "'"
                    sSQL = sSQL + ",`Payee`='" + xCont.txtPayee.Text.Trim.Replace("'", "\'") + "'"
                    sSQL = sSQL + ",`Borrower`='" + xCont.txtBorrower.Text.Trim.Replace("'", "\'") + "'"
                    sSQL = sSQL + ",`Seller`='" + xCont.txtSeller.Text.Trim.Replace("'", "\'") + "'"
                    sSQL = sSQL + ",`Prosperity Borrower`='" + xCont.txtPBorrower.Text.Trim.Replace("'", "\'") + "'"
                    sSQL = sSQL + ",`Prosperity Seller`='" + xCont.txtPSeller.Text.Trim.Replace("'", "\'") + "'"
                    sSQL = sSQL & " WHERE `Record Number` = '" & rNum & _
                                  "' AND `Line Number`='" + xCont.lblLine.Text.Trim.Replace("'", "\'") + "'"
                    MyDB.ExecQuery(sSQL, "wellsfargo")
                Else
                    Dim sColumn As String = ""

                    For z As Integer = 0 To dT.Rows.Count - 1
                        If z = 0 Then
                            sColumn = "`" & dT.Rows(z).Item(0).ToString & "`"
                        Else
                            sColumn = sColumn & ",`" & dT.Rows(z).Item(0).ToString & "`"
                        End If
                    Next
                    sSQL = "INSERT INTO `" + MyJob + "` (" + sColumn + ") VALUES (" + _
                    "'" + rNum + "'," + _
                    "'" + xHead.txtOrigBegDoc.Text.Trim.Replace("'", "\'") + "'," + _
                    "'" + xHead.txtOrigEndDoc.Text.Trim.Replace("'", "\'") + "'," + _
                    "'" + xHead.txtBegDoc.Text.Trim.Replace("'", "\'") + "'," + _
                    "'" + xHead.txtEndDoc.Text.Trim.Replace("'", "\'") + "'," + _
                    "'" + xHead.txtLoan.Text.Trim.Replace("'", "\'") + "'," + _
                    "'" + xHead.txtPage.Text.Trim.Replace("'", "\'") + "'," + _
                    "'" + xHead.txtPath.Text.Trim.Replace("'", "\'") + "'," + _
                    "'" + xHead.txtFileNumber.Text.Trim.Replace("'", "\'") + "'," + _
                    "'" + xHead.txtDate.Text.Trim.Replace("'", "\'") + "'," + _
                    "'" + xHead.txtLaF.Text.Trim.Replace("'", "\'") + "'," + _
                    "'" + xHead.txtComm.Text.Trim.Replace("'", "\'") + "'," + _
                    "'" + xCont.lblLine.Text.Trim.Replace("'", "\'") + "'," + _
                    "'" + xCont.cboDesc.Text.Trim.Replace("'", "\'") + "'," + _
                    "'" + xCont.txtAmount.Text.Trim.Replace("'", "\'") + "'," + _
                    "'" + xCont.txtPayee.Text.Trim.Replace("'", "\'") + "'," + _
                    "'" + xCont.txtBorrower.Text.Trim.Replace("'", "\'") + "'," + _
                    "'" + xCont.txtSeller.Text.Trim.Replace("'", "\'") + "'," + _
                    "'" + xCont.txtPBorrower.Text.Trim.Replace("'", "\'") + "'," + _
                    "'" + xCont.txtPSeller.Text.Trim.Replace("'", "\'") + "')"
                    MyDB.ExecQuery(sSQL, "wellsfargo")
                End If

            Next
 MsgBox("Record successfully modified!", MsgBoxStyle.Information, Me.Text)
4

1 回答 1

0

通常检查没有太大意义 - 如果出现问题,将引发异常。您可以将其包装到存储过程中并检查 @@rowcount 变量。或者真的只是做出新的选择来读取变化的数据。

于 2012-12-14T08:34:16.863 回答