Link to home
Start Free TrialLog in
Avatar of hainansyndrome
hainansyndrome

asked on

varbinary in datagridview, from data set

I am binding a dataset to a datagridview
in it there is a varbinary field which dsplays as a picture
if the field is null not problem but if It is not null then it crashed the datagrid
I want to edit teh dataset before i bind it,
if it is NULL then i want to show ""
if it is not null i want to just show"Encrypted Password"

I am ne to dotnet so I am relatively clueless where to start
where is what I have this far

 
Dim da As SqlDataAdapter = New SqlDataAdapter("Select * from security whereofficerid='" & ComboBox1.SelectedValue.ToString() & "'" & _
            " and pmrespersonid = '" & TextBox2.Text & "'", cn)
            Dim DS As DataSet = New DataSet
            da.Fill(DS)
 
            DataGridView1.DataSource = DS.Tables(0)
            DS.Dispose()
            cn.Close()

Open in new window

Avatar of Nasir Razzaq
Nasir Razzaq
Flag of United Kingdom of Great Britain and Northern Ireland image

You can do that with this statement

iif(isdbnull(field), "", "Encrypt Password")

Now you need to write this code in an event so that this code executes for each row.
ASKER CERTIFIED SOLUTION
Avatar of Bob Learned
Bob Learned
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of hainansyndrome
hainansyndrome

ASKER

yes i had thought about editing the query problem is i want to show every field in the table and did not want to have to write each field


CodeCruiser

can you give me an example of what you man to use that
i am not sure where to place it
before i write the dataset to a databridview?
works like a champ