# Re: 如何在一个DBGRID使用两个资料表(具关联性的)

Posted by KEVIN on March 16, 1999 at 14:58:27:

In Reply to: Re: 如何在一个DBGRID使用两个资料表(具关联性的) posted by AndyLin on March 12, 1999 at 09:28:36:

: : 请问一下,如何在一个DBGRID使用两个资料表(具关联性的),谢谢您的指导

: 如果你在 dbgrid 中只浏览而不修改,则只要在 select 叙述中 join 其他 table 就可以了.

I had same qusetion ,but I need to add ,delete and edit
and search two table and I need use adodc componment for vb6 and access.

I can not creat relation for two table with sql
because I add some information in one table
I can not sent relation information for other table .

could you give me some informaiton
thanks a lot

source code is
Option Explicit
Dim sn As String

Private Sub Command1_Click()

sn = Adodc1.Recordset.Fields(0).Value
Text2.Text = sn

Adodc2.RecordSource = "select * from spouse where FLECSCID ='sn'"

Set Text2.DataSource = Adodc2
Text2.DataField = "FLECSCID"
Text3.Text = sn

End Sub

Private Sub Form_Load()

With Adodc1

.ConnectionString = " Provider = Microsoft.Jet.OLEDB.3.51;Persist Security Info=False;Data Source=C:\My Documents\job\sucess\ver002\membership.mdb;Mode=Read|Write"

.RecordSource = "select * from membership where FLECSCNO='33333333'"
End With
Set Text1.DataSource = Adodc1
Text1.DataField = "FLECSCNO"

With Adodc2

.ConnectionString = " Provider = Microsoft.Jet.OLEDB.3.51;Persist Security Info=False;Data Source=C:\My Documents\job\sucess\ver002\membership.mdb;Mode=Read|Write"
Adodc1.Recordset.MoveFirst

sn = Adodc1.Recordset.Fields(0).Value
Text2.Text = Trim(sn)

.RecordSource = "select * from spouse where FLECSCID ='sn'"
End With

Set Text2.DataSource = Adodc2
Text2.DataField = "FLECSCID"
Text3.Text = sn

End Sub

Private Sub Text3_Change()
Text3.Text = sn
End Sub

Follow Ups: