我正在处理帐户权限管理,但我需要从 datagridview 输入更新 sql 数据库中表中的所有列,但一个特定列除外。谢谢!
身份证 | 客户名 | 活跃 | 团体 1 | 望路路| 1 | 1 2 | 李维斯贝尔| 0 | 2
Dim comm As New SqlCommand
Dim dbread As SqlDataReader
Dim adptr As New SqlDataAdapter
Dim dt As New DataTable
Dim ds As New DataSet
Dim myBuilder As SqlCommandBuilder
Private Sub lbldgvUserID_TextChanged(sender As Object, e As EventArgs) Handles lbldgvUserID.TextChanged
Try
conn.Open()
With comm
.Connection = conn
.CommandText = "SELECT ID,custName,Active,Group FROM tbl_customer WHERE ID= '" + lblUserID.Text + "'"
End With
adptr.SelectCommand = comm
'dt.Clear()
ds.Clear()
adptr.Fill(ds, "tbl_customer")
dgvPermissions.DataSource = ds.Tables("tbl_custorer").Rows(0)
Catch ex As Exception
MsgBox(ex.Message)
conn.Close()
End With
End Try
Dim builder As SqlCommandBuilder = New SqlCommandBuilder(adptr)
adptr.Update(ds, "tbl_customer")
MsgBox("Customer info successfuly updated!", MsgBoxStyle.Information)