2012-04-14 4 views
0

Hallo Freunde hier ist mein CodeAbfragen von Daten aus mehrere Tabelle von MS Access in Datenraster Blick in vb.net

connect() 
     cmd.CommandText = "Select RegID,Name,EmailID,DOB,State,Nation,Contact1 As Contact,ParmanentAdd as Address,Religion,WillNo as WillNumber,Will from SelfInformation" 
     cmd.Connection = cn 
     dr = cmd.ExecuteReader(CommandBehavior.CloseConnection) 
     tb.Clear() 
     tb.Load(dr) 
     DataGridView1.DataSource = tb 
     cmd.Dispose() 
     cn.Close() 

     'family......... 

connect() 
     'cmd.CommandText = "Select RegID,FName As Father,MName As Mother,MStatus As Marital,Degree,Childran As Children,NOC As NumberOfChild from Faimly" 
     'cmd.CommandType = CommandType.Text 
     'cmd.Connection = cn 
     'dr = cmd.ExecuteReader(CommandBehavior.CloseConnection) 
     'tb.Clear() 
     'tb.Load(dr) 
     'DataGridView1.DataSource = tb 
     'cmd.Dispose() 
     'cn.Close() 

die Daten nur die zweiten Tabellendaten in Datagrid Ansicht .i wollen Abrufen zum Laden von Daten aus beide Tabellen

bitte helfen

Antwort

0

Sie müssen sich registrieren zwei Tabellen in cmd.CommandText und in Datagridview zu laden.

cmd.CommandText = "Select si.RegID,si.Name,si.EmailID,si.DOB,si.State,si.Nation,si.Contact1 As Contact, " & _ 
      "si.ParmanentAdd as Address,si.Religion,si.WillNo as si.WillNumber,si.Will," & _ 
      "f.FName as Father, f.MName as Mother, f.MStatus as Marital, f.Degree, f.Childran As Children, f.NOC As NumberOfChild " & _ 
      " FROM SelfInformation si, Family f WHERE si.RegID = f.RegID" 
Verwandte Themen