Displaying data in datagrid

winsonlee

Member
Joined
Jan 5, 2008
Messages
10
Programming Experience
Beginner
I am using vb.net to develop an application. My database format is as displayed below. Can I display the data for credit in one column and debit in another column ? How can i achieve this ?

VB.NET:
Database
ID    | Date    | Type   | Descripton | Amount 
1        1/1/08    Credit    Rental         200.00
2        2/1/08    Debit     Salary         300.00


DataGrid

Date    | Descripton | Credit   | Debit
------------------------------------
1/1/08  |  Rental     |  200.00 |
2/1/08  |  Salary     |            | 300.00
 
you can probably use the case statement to populate your data columns.

VB.NET:
select [date], description, 
 case type when "Credit" then Amount else "" end as Credit,
 case type when "Debit" then Amount else "" end as Debit
From [table]
Where [blah blah blah]

you will probably need to perform type conversion, validation to prevent error when computing the totals.
 
Back
Top