checklistboxtan seçilenlerin sql sorguyla listelenmesi

Delphi'de kod yazma ile ilgili sorularınızı bu foruma yazabilirsiniz.
Cevapla
Kullanıcı avatarı
huseyinert
Üye
Mesajlar: 233
Kayıt: 19 Nis 2005 06:49
Konum: Bartın

checklistboxtan seçilenlerin sql sorguyla listelenmesi

Mesaj gönderen huseyinert »

Merhaba Arkadaşlar
query den sql ile aşağıda verdiğim şekilde checklistboxtan dbdride aktarmak istiyorum seçtiklerimi normal listboxa aktarıyor fakat query de sorguyu yenilediği için tek işaretlenen geliyor ben checklistboxtan seçtiğim hangi kayıtlar varsa ona göre gelmesini istiyorum
yardımlarınız için şimdiden teşekkürler.

Kod: Tümünü seç

var
  i: integer;
begin

for I := 0 to CheckListBox1.Items.Count - 1 do
  begin

    if CheckListBox1.Checked[i] then
    begin
     // ShowMessage('Item at index ' + IntToStr(i) + ' is selected.' +
       //           'Its value is '+ CheckListBox1.Items.Strings[i]);

personel_rapor.Close;
personel_rapor.UnPrepare;
personel_rapor.SQL.Clear;
personel_rapor.SQL.Add('select *from personel where sinifi='+#39+CheckListBox1.Items.Strings[i]+#39+' order by sinifi');
personel_rapor.Prepare;
personel_rapor.Open;

abc.Items.Add(CheckListBox1.Items.Strings[i]);

    end;
  end;
"Kula bela gelmez Hak yazmayınca,Hak bela yazmaz kul azmayınca..." MEVLANA
emrahgs
Üye
Mesajlar: 114
Kayıt: 08 Tem 2008 06:25
Konum: Antalya

Re: checklistboxtan seçilenlerin sql sorguyla listelenmesi

Mesaj gönderen emrahgs »

Bu Şekilde Denermisin
var
i: integer;
Sart:String;
begin
Sart:='';
for I := 0 to CheckListBox1.Items.Count - 1 do
begin

if CheckListBox1.Checked then
begin
Sart:=Sart+','+QuotedStr(CheckListBox1.Items.Strings);

end;
end;
if Sart<>'' then
Begin
delete(Sart,1,1);
Sart:=' and Sinifi in ('+Sart+')';
End;

personel_rapor.Close;
personel_rapor.UnPrepare;
personel_rapor.SQL.Clear;
personel_rapor.SQL.Add('select *from personel where 1=1 '+Sart);
personel_rapor.Prepare;
personel_rapor.Open;
Kullanıcı avatarı
huseyinert
Üye
Mesajlar: 233
Kayıt: 19 Nis 2005 06:49
Konum: Bartın

Re: checklistboxtan seçilenlerin sql sorguyla listelenmesi

Mesaj gönderen huseyinert »

Hocam teşekkür ederim istediğim gibi çalıştı çok sağol...
"Kula bela gelmez Hak yazmayınca,Hak bela yazmaz kul azmayınca..." MEVLANA
Kullanıcı avatarı
huseyinert
Üye
Mesajlar: 233
Kayıt: 19 Nis 2005 06:49
Konum: Bartın

Re: checklistboxtan seçilenlerin sql sorguyla listelenmesi

Mesaj gönderen huseyinert »

hocam bu olaya bir kaç tane daha checklistbox ekleyeceğim sql koduna diğer checkbox değerlerini getirmeye çalışıyorum or deyimi ile ayırmaya çalışıyorum ama olmadı yardımcı oabilirseniz sevinirim..

Kod: Tümünü seç

var
i,birim_i: integer;
Sart,birim_s:String;
begin
Sart:='';
for I := 0 to CheckListBox1.Items.Count - 1 do
begin

if CheckListBox1.Checked[i] then
begin
Sart:=Sart+','+QuotedStr(CheckListBox1.Items.Strings[i]);

end;
end;
if Sart<>'' then
Begin
delete(Sart,1,1);
Sart:=' and Sinifi in ('+Sart+')';
End;
//birimi başlangıç
birim_s:='';
for birim_i := 0 to CheckListBox2.Items.Count - 1 do
begin

if CheckListBox2.Checked[birim_i] then
begin
birim_s:=birim_s+','+QuotedStr(CheckListBox2.Items.Strings[birim_i]);

end;
end;
if birim_s<>'' then
Begin
delete(birim_s,1,1);
birim_s:=' and birimi in ('+birim_s+')';
End;
 //birim son
personel_rapor.Close;
personel_rapor.UnPrepare;
personel_rapor.SQL.Clear;
personel_rapor.SQL.Add('select *from personel where 1=1 '+Sart or '1=1 '+birim_s);
personel_rapor.Prepare;
personel_rapor.Open;
"Kula bela gelmez Hak yazmayınca,Hak bela yazmaz kul azmayınca..." MEVLANA
emrahgs
Üye
Mesajlar: 114
Kayıt: 08 Tem 2008 06:25
Konum: Antalya

Re: checklistboxtan seçilenlerin sql sorguyla listelenmesi

Mesaj gönderen emrahgs »

Kod: Tümünü seç

var
i,birim_i: integer;
Sart,birim_s:String;
begin
Sart:='';
for I := 0 to CheckListBox1.Items.Count - 1 do
begin

if CheckListBox1.Checked[i] then
begin
Sart:=Sart+','+QuotedStr(CheckListBox1.Items.Strings[i]);

end;
end;
if Sart<>'' then
Begin
delete(Sart,1,1);
Sart:=' Sinifi in ('+Sart+')';
End;
//birimi başlangıç
birim_s:='';
for birim_i := 0 to CheckListBox2.Items.Count - 1 do
begin

if CheckListBox2.Checked[birim_i] then
begin
birim_s:=birim_s+','+QuotedStr(CheckListBox2.Items.Strings[birim_i]);

end;
end;
if birim_s<>'' then
Begin
delete(birim_s,1,1);
birim_s:=' birimi in ('+birim_s+')';
End;
 //birim son
personel_rapor.Close;
personel_rapor.UnPrepare;
personel_rapor.SQL.Clear;
personel_rapor.SQL.Add('select *from personel where 1=1 ');
if (Sart <>'') and ('birim_s') Then
personel_rapor.SQL.Add(' or ('+Sart or '1=1 '+birim_s+')')
Else
if (Sart <>'')
personel_rapor.SQL.Add(' and '+Sart)
if '+birim_s<>'')
personel_rapor.SQL.Add(' and '+birim_s);


personel_rapor.Prepare;
personel_rapor.Open;
Kullanıcı avatarı
huseyinert
Üye
Mesajlar: 233
Kayıt: 19 Nis 2005 06:49
Konum: Bartın

Re: checklistboxtan seçilenlerin sql sorguyla listelenmesi

Mesaj gönderen huseyinert »

hocam çok teşekkürler...
"Kula bela gelmez Hak yazmayınca,Hak bela yazmaz kul azmayınca..." MEVLANA
Cevapla