ASP.Net load items – an efficient way to check for isDBNull to populate a control

This was the original way to check for a database field being null before putting it into a label:

if not isDBNull(dr(“FieldName”)) then

Me.label1.text = dr(“FieldName”).ToString

else

Me.label1.text = “”

end if

however there is a much better and more efficient way….

Me.label1.text = dr.field(of String)(“FieldName”)

Sorted!

Checking for null when querying a datatable or dataview in ASP.Net (VB)

You can check for null when applying a select or a filter to a datatable or dataview it is easy to filter by a field that is equal to something, but much more difficult to check if it is null.

For example (dataview):

        Dim dv As DataView = Db.GetData("uspDatabaseMenuiser_Select").Tables(0).AsDataView
        dv.RowFilter = "ParentMenuID = 0"
        dv.Sort = "MenuTitle ASC"
          

As you can see from the rowFilter we are getting where ParentMenuID = 0, but what if we want to check if ParentMenuID is null?

        Dim dv As DataView = Db.GetData("uspDatabaseMenuiser_Select").Tables(0).AsDataView
        dv.RowFilter = "IsNull(ParentMenuID, '') <> ''"
        dv.Sort = "MenuTitle ASC"


	

Folder called Reports requires extra username and password?

We have had a recurring, and very annoying problem on some of our live servers – when trying to access any folder in IIS called “reports” it was asking for additional login information, and not showing the actual content from the folder. A bit of digging revealed that the culprit was SQL Server 2008 R2 Reporting Services.

Turning off Reporting Services didnt have any effect, we just got a 503 Error.

Resolution:

Click on Start

Type in Reporting Services Configuration Manager

Click on Report Manager URL on the left hand side of the Reporting Services Configuration Manager – by default it is set to “Reports”, as you can see here, we have already changed ours to “SQLReports”

Please leave a comment if this has helped you resolve the same problem we had!