Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: Oracle VB.NET
Dim selected As String = ""
        For Each node As RadTreeNode In treedetails.Nodes
            If node.Checked = True Then
                selected += node.Value + ""
            End If
        Next
        tn &= " and a.zbaid in (" & selected & ")"
 

when i check though breakpoints this is whats happening
select distinct a.empno,a.name,a.empdesignation ,to_char(b.dtleavefrom,'dd-Mon-yyyy') as dtleavefrom  ,to_char(b.dtleaveto,'dd-Mon-yyyy') as dtleaveto,c.desp, DECODE(b.dtleaveto -b.dtleavefrom,0,1,b.dtleaveto -b.dtleavefrom) dAYS   from tt.employee a join dilpreet.leavedetails b on a.empno = b.empid join ranu.leavemaster c on b.leaveid = c.leaveid  where (b.status='C')  and b.dtleavefrom LIKE '%JAN-13%' and a.zbaid in (201123208210166212)
 
the a.zbaid feild shows my id like this when it is supposed to show it like (201,123,208,210,166,212)
please help
Posted 8-Jul-13 0:31am
Edited 8-Jul-13 0:32am
v2
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 2

 Dim selected As String = ""
        Dim sep As String = ""
        For Each node As RadTreeNode In treedetails.Nodes
            If node.Checked = True Then
                selected +=  node.Value & ","
            End If
        Next
        selected=selected.Substring(0, selected.Length - 1)
        tn &= " and a.zbaid in (" & selected & ")"
  Permalink  
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

IN clause requires a commas separated list: so add your comma in the loop:
        Dim selected As String = ""
        Dim sep As String = ""
        For Each node As RadTreeNode In treedetails.Nodes
            If node.Checked = True Then
                selected += sep + node.Value 
                sep = ","
            End If
        Next
        tn &= " and a.zbaid in (" & selected & ")"
But you would be better off using a StringBuilder, or assembling a List of strings, and using String.Join.
 
[edit]move separator to before clause...oops - OriginalGriff[/edit]
  Permalink  
v2
Comments
a2ulthakur at 8-Jul-13 7:53am
   
still it produces output like this
 

select distinct a.desgid,a.empno,a.name,a.empdesignation ,to_char(b.dtleavefrom,'dd-Mon-yyyy') as dtleavefrom ,to_char(b.dtleaveto,'dd-Mon-yyyy') as dtleaveto,c.desp, DECODE(b.dtleaveto -b.dtleavefrom,0,1,b.dtleaveto -b.dtleavefrom) dAYS from tt.employees a join dilpreet.leavedetails b on a.empno = b.empid join ranu.leavemaster c on b.leaveid = c.leaveid where (b.status='P' or b.status='PR' or b.status='AP') and b.dtleavefrom LIKE '%FEB-13%' and a.zbaid in (201123,208,210,)
OriginalGriff at 8-Jul-13 8:03am
   
:doh: I blame lack of coffee this morning - I have changed my code to fix it...

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
0 OriginalGriff 381
1 Sergey Alexandrovich Kryukov 245
2 Marcin Kozub 225
3 Praneet Nadkar 217
4 /\jmot 189
0 OriginalGriff 8,284
1 Sergey Alexandrovich Kryukov 7,407
2 DamithSL 5,614
3 Maciej Los 4,989
4 Manas Bhardwaj 4,986


Advertise | Privacy | Mobile
Web04 | 2.8.1411023.1 | Last Updated 8 Jul 2013
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100