我正在尝试使用更新数据库,SqlDataAdapter
但我的代码似乎不起作用:
Dim sitedb As String = BookingApp.Globals.siteDB
Dim conn As New SqlConnection(sitedb)
Dim sql As String = "select * from name where BOOKING_REF = 'H2124'"
Dim cmd As SqlCommand
Dim da As SqlDataAdapter
Dim cb As SqlCommandBuilder
Dim dt As New DataTable
Dim c As Integer
cmd = New SqlCommand(sql, conn)
da = New SqlDataAdapter(cmd)
cb = New SqlCommandBuilder(da)
da.Fill(dt)
For c = 0 To dt.Rows.Count - 1
dt.Rows(c)!OVLREF3 = c
dt.AcceptChanges()
Next
da.Update(dt)
据我所见,代码看起来还不错,有人有什么建议吗?
谢谢