Поддержка / Donate
 

WebMoney

Яндекс.Деньги

SMS.Копилка
Деньги@Mail.ru
Rupay
E-gold
PayPal

 

Благодарю за поддержку!

Лента RSS - Новости сайта Новости сайта
Лента RSS - Новости форума Новости форума
Добавить в закладки и поделиться Bookmark and Share

 

Архив исходников

 


Automatic translation

 
English German French
Italian Spanish Portuguese
Greece Japan Chinese
  Korean  

  

 

  Форум  

Delphi FAQ - Часто задаваемые вопросы

| Базы данных | Графика и Игры | Интернет и Сети | Компоненты и Классы | Мультимедиа |
| ОС и Железо | Программа и Интерфейс | Рабочий стол | Синтаксис | Технологии | Файловая система |



Google  
 

Поле с автоматически наращиваемым значением средствами SQL

Оформил: DeeCo
Автор: http://www.swissdelphicenter.ch

{ 
  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.GetNextNumber : 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.SetNextNumber;
 begin
  //You must first see if the table is in insert/update mode before using this procedure. 
 tblMain.FieldByName('FieldToIncrese').AsInteger := GetNextNumber;
 end;



Источник - Проект "Delphi World" © Выпуск 2002 - 2004
Автор проекта: Акулов Николай



   Rambler's Top100             Яндекс цитирования