The column derived from the database value essentially is based on the following pseudocode
If Issued_Quantity > 0, field value = Complete ("C")
Else, field value = Incomplete ("I")
Is there a way to incorporate this into the datagrid while still pulling two columns directly from the database?
My current code is as follows:
VB.NET |
Where the SQL statement is
VB.NET |
The desired end result would look something like this:
Requisition Number | Location | Status
1230957389 | Bay 2 | I
4357892346 | Bay 6 | C
The values in the database for status would be '0' for the first record and a number like '25' for the second.
Thank you in advance for your help!

Laura Ritchey3 reputationPosted Aug 26, 2010, 9:52 AM EDT
Dim dr As SqlCeDataReader Dim dt As DataTable Dim cmd As SqlCeCommand = New SqlCeCommand(sql, cn) cn.Open() dr = cmd.ExecuteReader Using dr dt = New DataTable dt.Load(dr) cn.Close() End Using Dim r As DataRow dt.Columns.Add("Status") dt.Columns(3).ReadOnly = False For i = 0 To dt.Rows.Count - 1 r = dt.Rows.Item(i) MsgBox(r.Item(2).ToString) If CInt(r.Item(2)) > 0 Then r.Item(3) = "C" Else r.Item(3) = "I" End If Next dt.Columns.Remove("Issued_Qty") Return dt