jump to navigation

Discovering Parent Directories May 06 2004

Ever wonder how to find the parent directory in VB.NET without messing with the path string?

=== BEGIN ===

Public Shared Function GetParentDirectory(ByVal strFileSystemPath As String) As String
Dim di As New System.IO.DirectoryInfo(strFileSystemPath)
Dim strParentDirectory = di.Parent.FullName.ToString & “”
Return (strParentDirectory)

End Function

=== END ===

File System Entries in a Data grid May 05 2004

Came across this solution while trying to interface with the local filesystem in ASP.NET (VB.NET) whatever the hell you wanna call it!

The problem was this; I’m used to binding data to a datagrid using a dataset, how do you bind data from the filesystem to the datagrid?

Here are the steps taken:

1. Create a DataTable by hand

e.g.
Dim dtblFileSystem As DataTable
dtblFileSystem = New DataTable(”file_system”)

2. Create the columns you want in the datatable

Dim dcolColumn As DataColumn

dcolColumn = New DataColumn(”inode_index”, GetType(Integer))
dtblFileSystem.Columns.Add(dcolColumn)

dcolColumn = New DataColumn(”inode_name”, GetType(String))
dtblFileSystem.Columns.Add(dcolColumn)

3. Get the …

Adding custom columns to datagrids May 04 2004

I came across this problem of adding a custom image column to my datagrid any time the unique row type changed. Since datagrid did not support
asp:image at run time, I needed to add the cell as the data was binding

=== BEGIN ===
Private Sub dgInodeList_OnItemDataBoundEventHandler( _
ByVal sender As System.Object, _
ByVal e As System.Web.UI.WebControls.DataGridItemEventArgs) _

finding Unique ID for rows in a datagrid while the data is binding!

Another one of those freaky VB.NET things is trying to determine the unique DB identifier for a datagrid row while the datagrid is bound to a data
set.

I used the OnItemDataBoundEventHandler to pick up the unique ID by recovering the bound data set and the index associated with the current item.

This is one of those M$ voodoo tricks I guess?

=== BEGIN ===

Private Sub dgInodeList_OnItemDataBoundEventHandler( _
ByVal sender As System.Object, _

VB.NET NULL Stored Procedure Parameters

Suppose you have a stored procedure that can accept a NULL value. In order to pass a NULL value in VB.NET this is not as simples as “NULL”

The correct thing to do is ‘System.DBNULL.Value’

Here is an example that will work:

=== BEGIN ===

Dim paramInodeParent As New SqlClient.SqlParameter
paramInodeParent = cmd.Parameters.Add (”@inode_parent_inode_id”,SqlDbType.Int, 4)
paramInodeParent.Direction = ParameterDirection.Input
If inode_parent_inode_id > 0 Then
paramInodeParent.Value = inode_parent_inode_id
Else
paramInodeParent.Value …