I have the following vb.net routine in an asp.net page:
Private Sub GetGridData( _
Optional ByVal sStatus As String = "New", _
Optional ByVal sBookmark As Char = "")
Dim sSQL As String
Dim sWHERE As String = "WHERE 1=1 "
If sStatus <> "Enabled" Then
sBookmark = ""
dlBookmark.Visible = False
' Do something else
sBookMark = "x"
sSQL = "SELECT * FROM MySQLView " & sWHERE
If sBookmark <> "" Then
' FixSQL wraps single quotes around a string
sSQL &= "AND Left(Name, 1) = " & FixSQL(sBookmark) & " "
sSQL &= "ORDER BY Status, Name"
Dim dr As SqlDataReader = dbHelper.OpenDataReader(sSQL)
MyDataGrid.DataSource = dr
This code no longer works when called as follows:
sBookmark has a value of nothing in the routine, not "", even after being assigned to string.empty. I know this used to work and I'm wondering if a change earlier this year from 1.1 to 2.0 / 3.0 / 3.5 treats chars differently. I can fix the code using a string instead of a char but I'm not sure why the car isn't set to an empty string either by the optional argument value or by the explicit assignment when status <> "Enabled".
Thanks in advance.