2

请帮我...

我在数据网格视图中加载我的数据库并编辑一些单元格。现在我只需要更新我的数据库

这是我的代码

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

    Dim sSQL As String = ""

    Dim dZ As DataTable = MyDB.ExecCommand("SELECT " & sColumn & " FROM `" + cboJob.Text.Trim + "`", "wellsfargo", 0).Tables(0)

    dColumn = New DataTable
    dColumn = MyDB.ExecCommand("SHOW COLUMNS IN tblrecord", "wellsfargo", 0).Tables(0)


    If dZ.Rows.Count <> 0 Then
        sSQL = "UPDATE " & sColumn & " FROM `" + cboJob.Text.Trim + "`"
        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 + ") "

        MyDB.ExecQuery(sSQL, "wellsfargo")
    End If
4

1 回答 1

0

完毕。我用这个代码..

 Try
        Cursor = Cursors.WaitCursor
        Dim sSQL As String
        sSQL = "UPDATE `" + cboJob.Text.Trim + "` SET `Description` ='" + TextBox1.Text + "' WHERE `Description`= '" + Label2.Text + "' AND `Line Number` ='" + comList.Text + "'"
        MyDB.ExecQuery(sSQL, "wellsfargo")
        MsgBox("Updated!")
        btnUpdate.Enabled = False

    Catch ex As Exception
        MsgBox("Select table first to Update")
    End Try
    Cursor = Cursors.Default
于 2012-11-08T07:34:33.850 回答