我想更改datagridview中显示的值是否有解决方案以及实际的数据库记录信息,如果联合则有100,000个,但每个表的“WRH”列的每个值只有一个值,除非有一张表有 2 个这样的值。
我要更改的数值信息如下:
001 BECOMES A
002 BECOMES B
003 BECOMES C
或者有其他解决方案请指导我
谢谢
Const constrA = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=|DataDirectory|\TABLEA.accdb;Persist Security Info=False;"
Const constrB = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=|DataDirectory|\TABLEB.accdb;Persist Security Info=False;"
Const constrC = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=|DataDirectory|\TABLEC.accdb;Persist Security Info=False;"
Function GetUsers(constr As String) As IEnumerable(Of Users)
Using con As OleDbConnection = New OleDbConnection(constr)
Return con.Query(Of Users)("SELECT * From Users Where WRH ='001' OR WRH ='002' OR WRH ='003'")
End Using
End Function
Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
DataGridView1.DataSource = GetUsers(constrA).Union(GetUsers(constrB)).Union(GetUsers(constrC)).ToList
End Sub
Public Class Users
Public Property Id() As Integer
Public Property Firstname() As String
Public Property LastName() As String
Public Property WRH() As String
End Class
表A:
Users
身份证 | 名字 | 姓氏 | WRH |
---|---|---|---|
1 | 测试1000 | 1000次测试 | 001 |
2 | 测试2000 | 2000次测试 | 001 |
表 B :
Users
身份证 | 名字 | 姓氏 | WRH |
---|---|---|---|
1 | 测试3000 | 3000次测试 | 002 |
2 | 测试4000 | 4000次测试 | 002 |
表C:
Users
身份证 | 名字 | 姓氏 | WRH |
---|---|---|---|
1 | 测试5000 | 5000次测试 | 003 |
2 | 测试6000 | 6000次测试 | 004 |
datagridview 中所需的结果
名字 | 姓氏 | WRH |
---|---|---|
测试1000 | 1000次测试 | A |
测试2000 | 2000次测试 | A |
测试3000 | 3000次测试 | B |
测试4000 | 4000次测试 | B |
测试5000 | 5000次测试 | C |