Click here to Skip to main content
11,641,416 members (58,124 online)
Rate this: bad
good
Please Sign up or sign in to vote.
See more: C#
Select CASE i.Installment_no 
            WHEN 1 THEN i.Loan_id, c.Customer_CNIC 
                   ELSE '' END AS LOAN_ID, 
            i.Installment_no, i.Date, i.Amount 
  from Installments i,
       Loan l,
       Customer c 
 where l.Loan_id = c.Loan_id 
   and c.Loan_id = i.Loan_id 
   and c.Customer_CNIC = '" + cbocnic1.Text + "-" + cbocnic2.Text + "-" + cbocnic3.Text + "' 
 order by l.Loan_id,i.Installment_no"
Posted 7-Jan-13 8:11am
Edited 7-Jan-13 8:15am
v2

1 solution

Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

This is SQL, not C#. Please tag your questions properly

I see you're building this SQL in C#, and that your SQL is built in the presentation layer, in a way that lets anyone erase or attack your DB. Read up on SQL injection attacks.

You should grab your SQL string and run it in management studio to debug it. However, the error means that it can't tell what c is, or that the column does not exist.

WHEN 1 THEN i.Loan_id, c.Customer_CNIC ELSE '' END AS LOAN_ID,


This does not work. It's probably the error. Get rid of it, you have when 1, which means you expect it to always run. I think you want

WHEN 1 THEN i.Loan_id ELSE '' END AS LOAN_ID, c.Customer_CNIC
  Permalink  
Comments
zeshanazam at 8-Jan-13 10:54am
   
i want output as
Loan_id Customer_CNIC Installment_No
1234-55 12345-12222-333 1
2
3
4

where and what i have to change in query ?
Christian Graus at 8-Jan-13 14:06pm
   
Write when statements to return blank strings where you want them.

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

  Print Answers RSS
0 Mika Wendelius 400
1 OriginalGriff 205
2 DamithSL 203
3 CPallini 185
4 Afzaal Ahmad Zeeshan 129


Advertise | Privacy | Mobile
Web02 | 2.8.150731.1 | Last Updated 7 Jan 2013
Copyright © CodeProject, 1999-2015
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