back up codes

always have a backup of your code

Archive for the tag “null value”

to display default value if database column is null

The following code will display a default value to an asp.net control if database column returns a null during databinding.


command = New Data.SqlClient.SqlCommand("SELECT * FROM MY_TABLE", connection)
reader = command.ExecuteReader()
If reader.Read() Then
If reader.Item("MY_COLUMN") IsNot DBNull.Value Then
txtbxValue.Text = reader("MY_COLUMN")
Else
txtbxValue.Text = 0
End If
Else
End If
reader.Close()

Post Navigation

Follow

Get every new post delivered to your Inbox.