G
Guest
Hi can someone please help!
I have been having issues with the following piece of code! Everytime I run
the application I get:
Exception Details: System.NullReferenceException: Object reference not set
to an instance of an object.
Source Error:
Line 70: topRow(" ") = "<img src='../images/user.gif'>"
Line 71:
Line 72: If res.Properties("sn").Count > 0 Then
Line 73: If res.Properties("sn")(0) Is Nothing Then
Line 74: Response.Write("Null")
I think this is because the value of "SN" in some records is null or
nothing! Can someone please help!
Thanks
Dim src As DirectorySearcher = New
DirectorySearcher("(&(objectCategory=Person)(objectClass=user))")
createTable()
src.SearchRoot = de
src.SearchScope = SearchScope.Subtree
For Each res As SearchResult In src.FindAll
Dim topRow As DataRow = ds.Tables("contacts").NewRow
topRow(" ") = "<img src='../images/user.gif'>"
If res.Properties("sn").Count > 0 Then
If res.Properties("sn")(0) Is Nothing Then
Response.Write("Null")
Else
topRow("Name") = res.Properties("sn")(0)
'topRow("Dept.") =
res.Properties("physicalDeliveryOfficeName")(0)
'topRow("Ext") = res.Properties("telephoneNumber")(0)
'topRow("Email") = res.Properties("mail")(0)
End If
End If
ds.Tables("contacts").Rows.Add(topRow)
Next
DataGrid1.DataSource = ds.Tables("contacts")
DataGrid1.DataBind()
End Sub
I have been having issues with the following piece of code! Everytime I run
the application I get:
Exception Details: System.NullReferenceException: Object reference not set
to an instance of an object.
Source Error:
Line 70: topRow(" ") = "<img src='../images/user.gif'>"
Line 71:
Line 72: If res.Properties("sn").Count > 0 Then
Line 73: If res.Properties("sn")(0) Is Nothing Then
Line 74: Response.Write("Null")
I think this is because the value of "SN" in some records is null or
nothing! Can someone please help!
Thanks
Dim src As DirectorySearcher = New
DirectorySearcher("(&(objectCategory=Person)(objectClass=user))")
createTable()
src.SearchRoot = de
src.SearchScope = SearchScope.Subtree
For Each res As SearchResult In src.FindAll
Dim topRow As DataRow = ds.Tables("contacts").NewRow
topRow(" ") = "<img src='../images/user.gif'>"
If res.Properties("sn").Count > 0 Then
If res.Properties("sn")(0) Is Nothing Then
Response.Write("Null")
Else
topRow("Name") = res.Properties("sn")(0)
'topRow("Dept.") =
res.Properties("physicalDeliveryOfficeName")(0)
'topRow("Ext") = res.Properties("telephoneNumber")(0)
'topRow("Email") = res.Properties("mail")(0)
End If
End If
ds.Tables("contacts").Rows.Add(topRow)
Next
DataGrid1.DataSource = ds.Tables("contacts")
DataGrid1.DataBind()
End Sub