DataGrid и наборы данных

Работа VB и СУБД (Access, MSSQL, MySQL, Oracle и пр.)
Правила форума
При создании новой темы не забывайте указывать используемую СУБД.
pstrkim
Новичок
Новичок
 
Сообщения: 30
Зарегистрирован: 03.01.2007 (Ср) 23:53

DataGrid и наборы данных

Сообщение pstrkim » 12.01.2007 (Пт) 11:15

Добрый день!
У меня есть DataGrid1 содержащий данные из двух таблиц БД Access,
связанных между собой по полю RawName
При попытке обновления поля RawName выдается ошибка DataGrid Control:
"Недостаточно сведений ключевого поля для обновления"
Проблема решается если связать DataGrid1 только с одной таблицей,
но мне нужно чтобы отображались данные из двух таблиц БД
Что можно сделать?

Antonariy
Повелитель Internet Explorer
Повелитель Internet Explorer
Аватара пользователя
 
Сообщения: 4824
Зарегистрирован: 28.04.2005 (Чт) 14:33
Откуда: Мимо проходил

Сообщение Antonariy » 12.01.2007 (Пт) 14:28

Запросы с объединением в общем случае не обновляются. Тем более не обновляются поля, по которым произошло объединение.
Лучший способ понять что-то самому — объяснить это другому.

Andrey Fedorov
Член-корреспондент академии VBStreets
Член-корреспондент академии VBStreets
 
Сообщения: 3287
Зарегистрирован: 21.05.2004 (Пт) 9:28
Откуда: Москва

Сообщение Andrey Fedorov » 12.01.2007 (Пт) 15:27

Antonariy писал(а):Запросы с объединением в общем случае не обновляются. Тем более не обновляются поля, по которым произошло объединение.


Ну почему не обновляются?

Для начала для RecordSet-a я бы указал свойство Unique Table.
Фиг Вам! - Сказал Чебурашка, обгладывая Крокодила Гену...

pstrkim
Новичок
Новичок
 
Сообщения: 30
Зарегистрирован: 03.01.2007 (Ср) 23:53

Сообщение pstrkim » 12.01.2007 (Пт) 20:25

Не понял свойство unique table?
Где это свойство?

Dmitriy2003
Постоялец
Постоялец
 
Сообщения: 690
Зарегистрирован: 27.05.2003 (Вт) 22:47
Откуда: Deutschland

Сообщение Dmitriy2003 » 12.01.2007 (Пт) 20:40

pstrkim писал(а):Не понял свойство unique table?
Где это свойство?


MSDN писал(а):ADO 2.7

Updating JOINed Results: Unique Table

ADO enables you to closely control modifications to a particular base table in a Recordset that was formed by a JOIN operation on multiple base tables using the Unique Table dynamic property. For details on using Unique Table, refer to the ADO Programmer's Reference topics on the Unique Table and Update Resynch dynamic properties.


после загрузки recordset (что-то вроде этого):

Код: Выделить всё
rsSample.Properties("Unique Table")= "Some Table Name"


MSDN Remarks писал(а):The desired base table is uniquely identified by its catalog, schema, and table names. When the Unique Table property is set, the values of the Unique Schema or Unique Catalog properties are used to find the base table. It is intended, but not required, that either or both the Unique Schema and Unique Catalog properties be set before the Unique Table property is set.

The primary key of the Unique Table is treated as the primary key of the entire Recordset. This is the key that is used for any method requiring a primary key.

While Unique Table is set, the Delete method affects only the named table. The AddNew, Resync, Update, and UpdateBatch methods affect any appropriate underlying base tables of the Recordset.

Unique Table must be specified before doing any custom resynchronizations. If Unique Table has not been specified, the Resync Command property will have no effect.

A run-time error results if a unique base table cannot be found.

These dynamic properties are all appended to the Recordset object Properties collection when the CursorLocation property is set to adUseClient.

Dmitrich


Вернуться в Базы данных

Кто сейчас на конференции

Сейчас этот форум просматривают: нет зарегистрированных пользователей и гости: 3

    TopList