Replace SELECT result before datagrid.
-
Hi I have the below sub the reads a single row table and populates the results in a data grid. Some of the fields have numerical values to represent settings. E.G. SecurityLevel 1 1 may be admin, so how to I replace the 1 with admin before I populate my datagrid? Dim Command1 As SqlCommand = New SqlCommand("SELECT [Name], Type, SecurityLevel, Version, CreatedDateTime, Driver, CabinetType, NetworkAddress, LoginFlag, DomainName, AuthenticationType, WebServerAddress FROM dbtab") Command1.CommandType = CommandType.Text Command1.Connection = SQLConnection1 myDataSet = New DataSet("myDataSet") SQLAdapter1.SelectCommand = Command1 SQLAdapter1.Fill(myDataSet, "Document") DataGrid2.SetDataBinding(myDataSet, "Document") About 4 of the Columns in the above select statment have values that I would like to replace bases on a lookup list. OK BIG point I CAN NOT make an intermediate table :-) Any thoughts When people make you see red, be thankful your not colour blind.
-
Hi I have the below sub the reads a single row table and populates the results in a data grid. Some of the fields have numerical values to represent settings. E.G. SecurityLevel 1 1 may be admin, so how to I replace the 1 with admin before I populate my datagrid? Dim Command1 As SqlCommand = New SqlCommand("SELECT [Name], Type, SecurityLevel, Version, CreatedDateTime, Driver, CabinetType, NetworkAddress, LoginFlag, DomainName, AuthenticationType, WebServerAddress FROM dbtab") Command1.CommandType = CommandType.Text Command1.Connection = SQLConnection1 myDataSet = New DataSet("myDataSet") SQLAdapter1.SelectCommand = Command1 SQLAdapter1.Fill(myDataSet, "Document") DataGrid2.SetDataBinding(myDataSet, "Document") About 4 of the Columns in the above select statment have values that I would like to replace bases on a lookup list. OK BIG point I CAN NOT make an intermediate table :-) Any thoughts When people make you see red, be thankful your not colour blind.
Replace
SecurityLevel
in your Sql statement with a case statement structured as needed.CASE WHEN SecurityLevel = 1 THEN 'Administrator' WHEN SecurityLevel = 2 THEN 'Supervisior' ELSE 'User' END As SecurityLevel,
-
Replace
SecurityLevel
in your Sql statement with a case statement structured as needed.CASE WHEN SecurityLevel = 1 THEN 'Administrator' WHEN SecurityLevel = 2 THEN 'Supervisior' ELSE 'User' END As SecurityLevel,