Re: Slow LDAP Query
From: Fred Hirschfeld (a_at_b.c)
Date: 03/09/05
- Next message: Marcos Stefanakopolus: "Re: Another arraylist cleanup question"
- Previous message: Kenneth H. Young: "Re: Slow LDAP Query"
- In reply to: Kenneth H. Young: "Re: Slow LDAP Query"
- Next in thread: Steven Cheng[MSFT]: "Re: Slow LDAP Query"
- Messages sorted by: [ date ] [ thread ]
Date: Wed, 9 Mar 2005 07:34:42 -0800
I think you will find this rewrite much more efficient that the one you had
previously:
Me.DataSet11.EnforceConstraints = False ' not sure if this will help in this
situation...
' Just the for loop
Dim results = mySearcher.FindAll As SearchResultCollection
For Each result In results
Dim props As PropertyCollection = result.GetDirectoryEntry().Properties
Data1 = GetValue(props, "cn")
Data2 = GetValue(props, "departmentNumber")
Data3 = GetValue(props, "buildingName")
Data4 = GetValue(props, "roomNumber")
Data5 = GetValue(props, "telephoneNumber")
Data6 = GetValue(props, "mail")
Data7 = GetValue(props, "employeeType")
Me.DataSet11.Employees.AddEmployeesRow(Data1, Data2, Data3, Data4, Data5,
Data6, Data7)
Me.DataSet11.AcceptChanges()
Next
Me.DataSet11.EnforceConstraints = True
...
Private Function GetValue(ByRef props As
System.DirectoryServices.PropertyCollection, ByVal name As String) As String
Dim propVal as Object = props(name).Value()
If IsNothing(propVal) Then
GetValue = "NA"
Else
Dim TestVal As String = props(name).Value.GetType.ToString
If TestVal = "System.String" Then
GetValue = propVal
ElseIf TestVal = "System.Object[]" Then
GetValue = propVal(0)
Else
GetValue = String.Empty ' This may not be what you want...
End If
End If
End Function
You may also want to look at using XML string with StringBuilder instead of
DataSet. You could then load this string result into a dataset in one shot.
Fred
"Kenneth H. Young" <young@ncst.nrl.navy.mil> wrote in message
news:Om%2362ZLJFHA.3928@TK2MSFTNGP09.phx.gbl...
> One thing I have notice is that if I don't write the results out to a
> text file, DataSet or TextBox the query (with 500 results) completes in
1.5
> seconds. Anything I try to pipe the results to increases the query to
> roughly 35 seconds for the same 500 results.
>
> Thanks once again for the continued help!
>
>
>
> "Steven Cheng[MSFT]" <v-schang@online.microsoft.com> wrote in message
> news:V3gsVfKJFHA.3472@TK2MSFTNGXA02.phx.gbl...
> > Hi Kenneth,
> >
> > From your former code snippet, you're currently insert all the datas
> > queried from the directorySearcher into a DataSet's DataTable and bind
the
> > datatable to a DataGrid, yes?
> >
> > I think this is OK. Also, you can just use a simple DataSet rather than
a
> > strong named one. Or you can just use a DataTable (no dataset needed)
and
> > directly bind the datatable to the DataGrid.
> >
> > In addition, we can also put our directory searching work into a
separate
> > worker thread when working in a desktop UI application, that'll help
> > improve the UI's interactive performance when the result is very large
> > which may take quite some time to finish. Here is a certain tech
article
> > discussing on the similar topic,
> >
> >
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dndotnet/ht
> > ml/dotnetadsearch.asp
> >
> > Hope also helps. Thanks,
> >
> > Regards,
> >
> > Steven Cheng
> > Microsoft Online Support
> >
> > Get Secure! www.microsoft.com/security
> > (This posting is provided "AS IS", with no warranties, and confers no
> > rights.)
> >
>
>
- Next message: Marcos Stefanakopolus: "Re: Another arraylist cleanup question"
- Previous message: Kenneth H. Young: "Re: Slow LDAP Query"
- In reply to: Kenneth H. Young: "Re: Slow LDAP Query"
- Next in thread: Steven Cheng[MSFT]: "Re: Slow LDAP Query"
- Messages sorted by: [ date ] [ thread ]
Relevant Pages
|