Sayfayı Yazdır | Pencereyi Kapat

SQL

Nereden Yazdırıldığı: Clomosy | Forum
Kategori: Genel Programlama
Forum Adı: Genel İşlemler
Forum Tanımlaması: TRObject dili ile programlama yaparken karşılaşılan genel işlemler
URL: https://forum.clomosy.com.tr/forum_posts.asp?TID=702
Tarih: 09 Ocak 2025 Saat 11:33
Program Versiyonu: Web Wiz Forums 12.07 - https://www.webwizforums.com


Konu: SQL
Mesajı Yazan: Hacer
Konu: SQL
Mesaj Tarihi: 19 Temmuz 2024 Saat 11:37
var
  anaForm: TclStyleForm;
  testImg: TClProImage;
  LocalQ: TClSqlQuery;
  quoteList: array of String;
  randomIndex: Integer;

void SetImage;
{
  testImg = anaForm.AddNewProImage(anaForm, 'testImg');
  
  clComponent.SetupComponent(testImg,
  '{
  "MarginBottom":50,
  "Width":50, 
  "Height":50,
  "BorderColor":"#ff94c8",
  "BorderWidth":3,
  "ImgUrl":" https://i.pinimg.com/550x/2d/1b/36/2d1b36a0f02dd5f0c663a8f58207ca01.jpg" rel="nofollow - https://i.pinimg.com/550x/2d/1b/36/2d1b36a0f02dd5f0c663a8f58207ca01.jpg" , 
  "ImgFit":"yes"}');

  anaForm.AddNewEvent(testImg, tbeOnClick, 'ShowRandomQuote');
}

void ShowRandomQuote;
{
  if (Length(quoteList) > 0)
  {
    randomIndex = Random(Length(quoteList));
    ShowMessage(quoteList[randomIndex]);
  }
  else
  {
    ShowMessage('No quotes available.');
  }
}

{
  Clomosy.DBSQLServerConnect('SQL Server', '172.16.222.147', 'hacer', '123456789', 'RepliklerDB', 50000);

  anaForm = TclStyleForm.Create(Self);
  LocalQ = TClSqlQuery.Create(nil);
  quoteList = [];

  try
  
    LocalQ.Connection = Clomosy.DBSQLServerConnection;
    LocalQ.SQL.Text = 'SELECT replik AS MAIN_TEXT FROM Replikler';
    LocalQ.Open;

    LocalQ.First;
  
    while (NOT LocalQ.EOF)
    {
      quoteList.Add(LocalQ.FieldByName('MAIN_TEXT').AsString);
      LocalQ.Next;
    }
  
  except
  
    ShowMessage('hata');
  }
  LocalQ.Free;

  anaForm.SetFormColor('#ffe5fa', '#e6ffe5', clGVertical);
  SetImage;
  anaForm.Run;
}
"SQL'e bağlanmıyor."



Cevaplar:
Mesajı Yazan: Developer
Mesaj Tarihi: 19 Temmuz 2024 Saat 16:02
Merhaba Hacer,
Kodları kontrol eder misin?
var
  anaForm: TclStyleForm;
  testImg: TClProImage;
  LocalQ: TClSqlQuery;
  quoteList: TclArrayString;
  randomIndex: Integer;

void ShowRandomQuote;
{
  if (quoteList.count > 0)
  {
    randomIndex = clMath.GenerateRandom(0,quoteList.count);
    ShowMessage(quoteList.GetItem(randomIndex));
  }
  else
  {
    ShowMessage('No quotes available.');
  }
}




void SetImage;
{
  testImg = anaForm.AddNewProImage(anaForm, 'testImg');
  
  clComponent.SetupComponent(testImg,
  '{
  "MarginBottom":50,
  "Width":50, 
  "Height":50,
  "BorderColor":"#ff94c8",
  "BorderWidth":3,
  "ImgUrl":" https://i.pinimg.com/550x/2d/1b/36/2d1b36a0f02dd5f0c663a8f58207ca01.jpg" rel="nofollow - https://i.pinimg.com/550x/2d/1b/36/2d1b36a0f02dd5f0c663a8f58207ca01.jpg" , 
  "ImgFit":"yes"}');

  anaForm.AddNewEvent(testImg, tbeOnClick, 'ShowRandomQuote');
}



{
   try
      Clomosy.DBSQLServerConnect('SQL Server', '192.168.5.11', 'sa', 'axoft', 'PRATIK24', 1433);
   except
     ShowMessage('Exception Class: '+LastExceptionClassName+' Exception Message: '+LastExceptionMessage);
   }
 

  anaForm = TclStyleForm.Create(Self);
  LocalQ = TClSqlQuery.Create(nil);
  quoteList = TclArrayString.Create;

  try
  
    LocalQ = Clomosy.DBSQLServerQueryWith('select kisi_adi as MAIN_TEXT from vardiyaa');
    LocalQ.Open;

    LocalQ.First;
  
    while (NOT LocalQ.EOF)
    {
      quoteList.Add(LocalQ.FieldByName('MAIN_TEXT').AsString);
      LocalQ.Next;
    }
  
  except
    ShowMessage('Exception Class: '+LastExceptionClassName+' Exception Message: '+LastExceptionMessage);
  }
  LocalQ.Free;

  anaForm.SetFormColor('#ffe5fa', '#e6ffe5', clGVertical);
  SetImage;
  anaForm.Run;
}



Sayfayı Yazdır | Pencereyi Kapat

Forum Software by Web Wiz Forums® version 12.07 - https://www.webwizforums.com
Copyright ©2001-2024 Web Wiz Ltd. - https://www.webwiz.net