Delphi Dünyası Facebook'ta

Kodbank İndir

! CODEBANK 2012 !

İNDİRMEK&DETAYLI BİLGİ ALMAK İÇİN BURAYI TIKLAYINIZ.

Gönderen Konu: Tablo Adını Değiştirmek  (Okunma sayısı 2008 defa)

0 Üye ve 1 Ziyaretçi konuyu incelemekte.

Çevrimdışı CMNSOFT

  • Delphi 2 Level 4
  • ****
  • İleti: 82
  • Rep: +2/-2
  • Cinsiyet: Bay
    • http://www.cmnsoft.com
Tablo Adını Değiştirmek
« : 13 Ekim 2005 14:16:53 »
Alıntı
Belirtilen tablonun adını değiştirir. Bu fonksiyon kullanılırken, veri



tabanındaki referans sınırlamalarına dikkat edilmelidir. SQL tabanlı veri



tabanlarında, eğer tabloya referans eden başka veri tabanı nesneleri varsa,



tablonun silinmesine izin verilmeyecektir.




Codec By GeNiUS !



Kod:  (Unknown Language)
  1. Function DBReNameTable(
  2.  
  3.   DatabaseName,
  4.  
  5.   TableNameOld,
  6.  
  7.   TableNameNew: String): Boolean;
  8.  
  9. Begin
  10.  
  11.   Result := True;
  12.  
  13.   Try
  14.  
  15.     If Not IsTable(DatabaseName, TableNameOld) Then
  16.  
  17.     Begin
  18.  
  19.       Result := False;
  20.  
  21.       Exit;
  22.  
  23.     End;
  24.  
  25.  
  26.  
  27.     {First Copy The Source Table To The New Table}
  28.  
  29.     If Not DBCopyTable(
  30.  
  31.              DatabaseName,
  32.  
  33.              TableNameOld,
  34.  
  35.              DatabaseName,
  36.  
  37.              TableNameNew) Then
  38.  
  39.     Begin
  40.  
  41.       Result := False;
  42.  
  43.       Exit;
  44.  
  45.     End;
  46.  
  47.  
  48.  
  49.     {Now Drop The Source Table}
  50.  
  51.     If Not DBDropTable(DatabaseName, TableNameOld) Then
  52.  
  53.     Begin
  54.  
  55.       Result := False;
  56.  
  57.       Exit;
  58.  
  59.     End;
  60.  
  61.   Except
  62.  
  63.     Result := False;
  64.  
  65.   End;
  66.  
  67. End;
  68.  
  69.  
  70.  
  71. {!~ Applies BatchMode Types As Appropriate To
  72.  
  73. Source and Destination Tables}
  74.  
  75. Function DBRecordMove(
  76.  
  77.            SourceDatabaseName,
  78.  
  79.            SourceTable,
  80.  
  81.            DestDatabaseName,
  82.  
  83.            DestTable: String;
  84.  
  85.            BMode: TBatchMode): Boolean;
  86.  
  87. var S : TTable;
  88.  
  89.     D : TTable;
  90.  
  91.     B : TBatchMove;
  92.  
  93. begin
  94.  
  95.   S := TTable.Create(nil);
  96.  
  97.   D := TTable.Create(nil);
  98.  
  99.   B := TBatchMove.Create(nil);
  100.  
  101.   try
  102.  
  103.     {Create The Source Table}
  104.  
  105.     S.Active       := False;
  106.  
  107.     S.DatabaseName := SourceDatabaseName;
  108.  
  109.     S.ReadOnly     := False;
  110.  
  111.     S.TableName    := SourceTable;
  112.  
  113.     S.Active := true;
  114.  
  115.  
  116.  
  117.     {Create The Destination Table}
  118.  
  119.     D.Active       := False;
  120.  
  121.     D.DatabaseName := DestDatabaseName;
  122.  
  123.     D.TableName    := DestTable;
  124.  
  125.     D.ReadOnly     := False;
  126.  
  127.  
  128.  
  129.     {Make the table copy}
  130.  
  131.     B.AbortOnKeyViol := False;
  132.  
  133.     B.AbortOnProblem := False;
  134.  
  135.     B.Destination    := D;
  136.  
  137.     B.Source         := S;
  138.  
  139.     B.Mode           := BMode;
  140.  
  141.     Try
  142.  
  143.       B.Execute;
  144.  
  145.     Except
  146.  
  147.     End;
  148.  
  149.  
  150.  
  151.     Result:= True;
  152.  
  153.   finally
  154.  
  155.     S.Free;
  156.  
  157.     D.Free;
  158.  
  159.     B.Free;
  160.  
  161.   end;
  162.  
  163. End;
:::::::::::::::::::: www.CMNSOFT.com ::::::::::::::::::::