Oct 20 2007

Conversion from type ‘DBNull’ to type ‘String’ = ghey

Here’s a quick fix when you get this error from retrieving data from a database. Just append .ToString to the field and it’ll convert the field to “” (nothing) first.

myDataSet.Tables(“tblStuff”).Rows(0).Item(“fldThing”).ToString

ps. joe taught me this ;)

Here’s a wrapper I use to test for null values that aren’t strings in the databse:

If Not myDataSet.Tables(“tblStuff”).Rows(0).Item(“fldNumber”) Is DBNull.Value Then
lngNumber = myDataSet.Tables(“tblStuff”).Rows(0).Item(“fldNumber”)
End If

joe didn’t teach me this one =)


Oct 20 2007

Joe is a .NET god! ;)

Yep, joe is the source of all my .net ideas. From there it’s to google, and then back to joe, and then to google some more.

Just wanted to share ;)


Oct 20 2007

When you have a massive migraine….

Don’t eat an entire bag of bbq potato chips down with some coke.

Do take 4 Advil, 3 Ibuprofen, and a prescription headache pill.

It’ll knock you and your headache out.

Warning… This does have a weird effect of slowing your breathing down. Thought I was gunna not wake up. But my head hurt so bad that I just didn’t care.

Results may vary.


Oct 20 2007

Getting data from master pages in child pages

Here’s an example that I used to dynamically change the meta tags in my page:

Master Page: VB:

Public Property MetaDescription() As String
Get
Return Page.Header.Attributes.Item(“Description.Content”)
End Get
Set(ByVal value As String)
Dim Description As New HtmlMeta
Description.Name = “description”
Description.Content = value
Page.Header.Controls.Add(Description)
End Set
End Property

Public Property MetaKeywords() As String
Get
Return Page.Header.Attributes.Item(“Keywords.Content”)
End Get
Set(ByVal value As String)
Dim Keywords As New HtmlMeta
Keywords.Name = “keywords”
Keywords.Content = value
Page.Header.Controls.Add(Keywords)
End Set
End Property

Then set / retrieve the data from the child page:

Child: VB:

Master.MetaDescription = “”
Master.MetaKeywords = “”

You also want to make sure that you put this bit of code in the child page aspx file:

<%@ MasterType VirtualPath=”~/Global.master” %>