3

I use a Select query to fill a DataTable from an SQL table and then use that DataTable as a DataSource for my DataGridView.

In my SQL table I have a column named 'status' that contains values between 1-3. When I display my dgv on my form I want every cell on column 'status' with value of 1 to change to "open".

How can I do that?

Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
Roi Snir
  • 411
  • 1
  • 4
  • 13

2 Answers2

1

Try something like this in your Select Query,

SELECT (CASE [status] WHEN 1 THEN 'Open' END) AS [status]
FROM table1
Abdul Rasheed
  • 6,486
  • 4
  • 32
  • 48
1

You can use CASE statement:

SELECT CASE WHEN [status] = 1 THEN 'Open' 
            WHEN [status] = 2 THEN 'Something else' 
            ELSE 'One more time' END AS [status]
FROM table1
gofr1
  • 15,741
  • 11
  • 42
  • 52