sn might equal nothing in some cases!
Do I need to put in some kind of error capture statement???
If so how would I write it???
Perhaps something LIKE this???
Thanks for the response!
Dim src As DirectorySearcher = New
DirectorySearcher("(&(objectCategory=Person)(objec tClass=user))")
createTable()
src.SearchRoot = de
src.SearchScope = SearchScope.Subtree
For Each res As SearchResult In src.FindAll
If res.Properties("sn")(0) is Nothing then
response.write ("Null")
Else
Dim topRow As DataRow = ds.Tables("users").NewRow
topRow("Name") = res.Properties("sn")(0)
ds.Tables("users").Rows.Add(topRow)
End If
Next
DataGrid1.DataSource = ds.Tables("users")
DataGrid1.DataBind()
"Joseph Byrns" wrote:
Where does the error occur? Looking at the code either de is nothing or
Table("users") is nothing.
"Tim::.." <myatix_at_hotmail.com> wrote in message
news:E4**********************************@microsof t.com... Can someone please tell me why I keep getting the following error! And how
do
I resolve the problem???
Thanks
System.NullReferenceException: Object reference not set to an instance of
an
object.
Dim src As DirectorySearcher = New
DirectorySearcher("(&(objectCategory=Person)(objec tClass=user))")
createTable()
src.SearchRoot = de
src.SearchScope = SearchScope.Subtree
For Each res As SearchResult In src.FindAll
Dim topRow As DataRow = ds.Tables("users").NewRow
topRow("Name") = res.Properties("sn")(0)
ds.Tables("users").Rows.Add(topRow)
Next
DataGrid1.DataSource = ds.Tables("users")
DataGrid1.DataBind()