img
00:00
imgDRKB online - Создание автоинкрементного поля SQL запросом?
imgimgimg
  
  [drkb=2009] Комментариев: 0 
Создание автоинкрементного поля SQL запросом?


delphi
{
  Lets say that we wish to create a fallawing number (Autoincrese) of an item,
  without using the AutoIncrese filed.
  This is usfull when for example there is more users from the same IP that log
  in or any other things that you wish.

  This example will show you how to do it with some checking of filled data,
  but it can be done anyway you wish.

  You need a Table with at least 2 fileds with number casting, and a TQUERY component.
}



function TForm1.GetNumber : integer;
begin
qryMain.Active := False;
qryMain.SQL.Clear;
qryMain.SQL.Add('Select Max(FieldToIncrease) from tblMain where (Cheking >=1);');
qryMain.Active := True; //We executed the query

if qryMain.RecordCount >= 0 then
  result := qryMain.FieldByName('FieldToIncrese').AsInteger +1;
else result := 1;
end;

...

procedure TForm1.SetNumber;
begin
//You must first see if the table is in insert/update mode before using this procedure.
tblMain.FieldByName('FieldToIncrese').AsInteger := GetNumber;
end;




@Drkb::02620
Взято с сайта http://www.swissdelph...ndex.php
Количество статей: 4366
 
Вход
Имя:
Пароль:
Запомнить
Регистрация Забыли пароль?
Мини-чат :)
Необходима регистрация
Архив мини-чата
26-03-2024 15:49
Roan
Надеюсь, оно ещё живо. Классный ресурс
03-03-2024 16:34
ПаХаН
Надо чтобы этот сайт был жив
20-02-2024 06:12
memoryspeak
обалденный сайт. искал ответ на вопрос, как скриптом закрыть вкладку, и наткнулся на это чудо.
08-02-2024 20:22
stark452
Разработчику огромный респект
08-02-2024 20:21
stark452
Если ее немного допилить
и сделать все правильно
то она может стать чем то весомым
08-02-2024 20:20
stark452
Странно что эта штука не популярна
08-10-2023 02:39
Darian
smiley
just testing the smileys
08-10-2023 02:38
Darian
._. -_- >o) ;(
08-10-2023 02:37
Darian
smiley
08-10-2023 02:36
Darian
smiley smiley smiley smiley :$ :?
Emoji Test
Статистика
 СегодняВсего
Посетителей63934101714
Запросов127570395537136
Online
Пользователей0
Гостей363
imgimgimgimg
 
img
     00:00