Reputation: 441
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?
Upvotes: 3
Views: 175
Reputation: 15977
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
Upvotes: 1
Reputation: 6719
Try something like this in your Select Query,
SELECT (CASE [status] WHEN 1 THEN 'Open' END) AS [status]
FROM table1
Upvotes: 1