
Новые сообщения [новые:0]
Дайджест
Горячие темы
Избранное [новые:0]
Форумы
Пользователи
Статистика
Статистика нагрузки
Мод. лог
Поиск
|
|
16.04.2004, 13:35
|
|||
|---|---|---|---|
Как узнать номер автоинкремента? |
|||
|
#18+
Вот этот код работал на xp, но на 95 перестал...может быть можно иначе узнать? Previous Top Next We have a table in MsAccess like : Test, Fields (id=autoinc, name=text); First we have to have a function like the one below : function GetLastInsertID: integer; begin // datResult = TADODataSet datResult.Active := False; datResult.CommandText := 'select @@IDENTITY as [ID]'; datResult.Active := True; Result := datResult.FieldByName('id').AsInteger; datResult.Active := False; end; Now before getting the last inserted record record id = autoincrement field, in other words calling the above function. You have to do a SQL insert like the following procedure InsertRec; begin // datCommand = TADOCommand datCommand.CommandText := 'insert into [test] ( [name] ) values ( "Test" )'; datCommand.Execute; end; Now if we like to know which is the last autoinc value ( notice that the getlastinsertid proc. only works after the insertrec proc) procedure Test; begin InsertRec; Showmessage(format('lastinsertid : %d', [GetLastInsertID])); end; Hope you can make this work, it works for me, any questions feel free to ask ... |
|||
|
:
Нравится:
Не нравится:
|
|||
|
|
|
16.04.2004, 13:45
|
|||
|---|---|---|---|
Как узнать номер автоинкремента? |
|||
|
#18+
XP и 95 - это версии Windows или Access? ... |
|||
|
:
Нравится:
Не нравится:
|
|||
|
|
|
16.04.2004, 13:47
|
|||
|---|---|---|---|
Как узнать номер автоинкремента? |
|||
|
#18+
XP и 95 Access я хотел сказать....та функция с 95 возращает все время 0... ... |
|||
|
:
Нравится:
Не нравится:
|
|||
|
|
|
16.04.2004, 13:50
|
|||
|---|---|---|---|
Как узнать номер автоинкремента? |
|||
|
#18+
в 95 нет @@IDENTITY ;) ... |
|||
|
:
Нравится:
Не нравится:
|
|||
|
|
|
16.04.2004, 13:52
|
|||
|---|---|---|---|
Как узнать номер автоинкремента? |
|||
|
#18+
а что есть? я в базах просто не очень силен... ... |
|||
|
:
Нравится:
Не нравится:
|
|||
|
|
|
16.04.2004, 13:55
|
|||
|---|---|---|---|
Как узнать номер автоинкремента? |
|||
|
#18+
Делается примерно таким образом: Код: plaintext 1. 2. 3. 4. 5. ID - это имя поля которое содержит AutoNumber ... |
|||
|
:
Нравится:
Не нравится:
|
|||
|
|
|

start [/forum/topic.php?fid=45&mobile=1&tid=1675273]: |
0ms |
get settings: |
11ms |
get forum list: |
13ms |
check forum access: |
3ms |
check topic access: |
3ms |
track hit: |
62ms |
get topic data: |
8ms |
get forum data: |
2ms |
get page messages: |
34ms |
get tp. blocked users: |
1ms |
| others: | 239ms |
| total: | 376ms |

| 0 / 0 |
