我必须遍历整个架构并获取具有特定列的所有表。然后从表格和列中我需要搜索特定值,然后更新该值。
以下就是我所拥有的
Public Function MassDataFieldUpdate(ByVal Column As List(Of String), ByVal whereClause As String) As DataTable
Dim temp As String = ""
Dim cSQL As String = String.Format("SELECT TABLE_NAME, COLUMN_NAME FROM information_schema.columns WHERE find_in_set(COLUMN_NAME, 'idUnit') > 0")
Return _Inst.GetTable(cSQL)
End Function
这个函数给我一个数据表,它是:
现在我想在datatable上编写另一个查询/ LINQ并遍历到行值为24的所有列并将其更改为88.
因此,如果在表格tblContact
中,则列“idUnit'有价值24我需要将其更新为' 88'请指导我。
这就是我现在所拥有的:
LOGIC.VB
Public Sub MassDataFieldUpdate()
Dim dt As New DataTable
Dim Column As List(Of String) = New List(Of String)
Select Case mode
Case SMS_Obj.Enumerations.DataUpdateMode.UnitId
Column.Add("idUnit")
Case SMS_Obj.Enumerations.DataUpdateMode.Unknown
' -1
Case Else
' nothing
End Select
dt.Merge(MassDataFieldUpdate(Column))
'WHAT LINQ QUERY NEEDS TO BE WRITTEN HERE
' I need to call 'MassRowUpdate' HERE
End Sub
DAL.vb
Public Function MassDataFieldUpdate(ByVal Column As List(Of String)) As DataTable
Dim temp As String = ""
Dim cSQL As String = String.Format("SELECT TABLE_NAME, COLUMN_NAME FROM information_schema.columns WHERE find_in_set(COLUMN_NAME, '{0}') > 0)", Column)
Return _Inst.GetTable(cSQL)
End Function
Public Sub MassRowUpdate(ByVal table_name As String, ByVal Column As List(Of String), ByVal whereClause As String)
Dim cSQL As String = String.Format("UPDATE {0} FROM {1} SET {2} {3}", table_name, Column, whereClause)
End Sub