Недавно добавленные исходники

•  TDictionary Custom Sort  3 225

•  Fast Watermark Sources  2 990

•  3D Designer  4 750

•  Sik Screen Capture  3 259

•  Patch Maker  3 467

•  Айболит (remote control)  3 528

•  ListBox Drag & Drop  2 904

•  Доска для игры Реверси  80 774

•  Графические эффекты  3 843

•  Рисование по маске  3 171

•  Перетаскивание изображений  2 544

•  Canvas Drawing  2 672

•  Рисование Луны  2 500

•  Поворот изображения  2 092

•  Рисование стержней  2 119

•  Paint on Shape  1 524

•  Генератор кроссвордов  2 183

•  Головоломка Paletto  1 730

•  Теорема Монжа об окружностях  2 158

•  Пазл Numbrix  1 649

•  Заборы и коммивояжеры  2 016

•  Игра HIP  1 262

•  Игра Go (Го)  1 200

•  Симулятор лифта  1 422

•  Программа укладки плитки  1 177

•  Генератор лабиринта  1 512

•  Проверка числового ввода  1 297

•  HEX View  1 466

•  Физический маятник  1 322

•  Задача коммивояжера  1 357

 
скрыть


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

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



Delphi Sources

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



Оформил: DeeCo

{ 
  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;




Похожие по теме исходники

Конструктор тестов SQL

SQL Zapros




Copyright © 2004-2024 "Delphi Sources" by BrokenByte Software. Delphi World FAQ

Группа ВКонтакте