-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 に答える