Страница: 1 | 
		
		
			
	
		 
		
			
  
    |  | Вопрос: Связка таблиц без RI вADO | Добавлено: 29.12.03 10:05 |  | 
		
			
			  
    
      | Автор вопроса:  volodiam | 
    
      | Имею одну таблицу с KeyPrimary,Autoincriment и другую просто с индексом и повторяющимися номерами.Не могу их связать без Referential Integrity.В KeyForeign  adRINone почему то не срабатывает.В принципе при SQL запросе вывожу то что хочеться,но просто интересно - в DAO получалось связать как угодно,а в ADO - знаний не хватает.Подскажите,пожалуйста. Ответить
       | 
  
		
			
		
		
			
		
	  
    
      | Номер ответа: 1 Автор ответа:
 
  ol2003 
 
  
 Вопросов: 3
 Ответов: 122
 
 | Профиль |  | #1 | Добавлено:  30.12.03 18:16 | 
    
      | | Сам я это не пробовал, но Wrox предлагает такой пример: ImportsSystem.Data.SqlClient Dimcnt As SqlConnection, sCnt As String, da As SqlDataAdapter, ds As DataSetPrivate Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load sCnt = "..." 'connection string cnt = New SqlConnection(sCnt) da = New SqlDataAdapter("select * from customers; select * from orders; select * from [order details]", cnt) ds = New DataSet()'we use this to get primary key for the tables da.MissingSchemaAction = MissingSchemaAction.AddWithKey da.Fill(ds)'name tables to match the source ds.Tables(0).TableName = "CUSTOMERS" ds.Tables(1).TableName = "ORDERS" ds.Tables(2).TableName = "ORDER_DETAILS"'create a new foreign key constraint between the customers'and order tables on the customer id fieldDim Parent As DataColumn = ds.Tables(0).Columns("CustomerID")Dim Child As DataColumn = ds.Tables(1).Columns("CustomerID")Dim CustomerIDConst As New ForeignKeyConstraint(Parent, Child) ds.Tables(1).Constraints.Add(CustomerIDConst)End Sub Сам не проверял, так что не взыщи  |  |  | 
 Ответить
       | 
  
Страница: 1 | 
 
		
			Поиск по форуму