ZekeLA
asked on
Why is optional char argument nothing, not empty string?
I have the following vb.net routine in an asp.net page:
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.
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
Else
' Do something else
sBookMark = "x"
End If
sSQL = "SELECT * FROM MySQLView " & sWHERE
If sBookmark <> "" Then
' FixSQL wraps single quotes around a string
sSQL &= "AND Left(Name, 1) = " & FixSQL(sBookmark) & " "
End If
sSQL &= "ORDER BY Status, Name"
Dim dr As SqlDataReader = dbHelper.OpenDataReader(sSQL)
MyDataGrid.DataSource = dr
MyDataGrid.DataBind()
End Sub
This code no longer works when called as follows:
GetGridData()
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.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER