表1=Table_HKB
表2=userdy
思路怎么来想呢,就是DataGrid1中要显示的内容是表1的内容,不过在显示之前要对表2进行查询后显示表1的内容就是不要显示表2已有的内容,
表1=Table_HKB
表2=userdy
思路怎么来想呢,就是DataGrid1中要显示的内容是表1的内容,不过在显示之前要对表2进行查询后显示表1的内容就是不要显示表2已有的内容,
ACCESS数据库
Private Sub Form_Load()
Dim strAppPath As String strAppPath = App.Path If Right(strAppPath, 1) <> "\" Then strAppPath = strAppPath & "\" End If strAppPath = strAppPath & "BigText.mdb" ConnectString = "DRIVER=Microsoft Access Driver (*.mdb);DBQ=" & strAppPath & "" Set cnn = New ADODB.Connection cnn.Open ConnectString
end sub
SQL数据库
private sub from_load()
Dim cnn As ADODB.Connection Dim rs As ADODB.Recordset Dim str As String
cnn.CursorLocation = adUseClient str = "Provider=SQLOLEDB.1;Persist Security Info =False;" _ & "User ID=sa;" _ & "Pwd=13802221802;" _ & "Initial Catalog=db1;" _ & "Data Source=whx"
cnn.Open str end sub
private command1_click()
dim str as string
str="select 人口编号 from Table_HKB where 人口编号 not in(select 人口编号 from userdy ) "
rs.open str,cnn,adopenstatic
datagrid1.datasoure=rs.recordset
end sub