Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > ASP .Net Datagrid Control > Problems displaying data from OleDb Provider

Reply
Thread Tools

Problems displaying data from OleDb Provider

 
 
Mick Heywood
Guest
Posts: n/a
 
      11-29-2004
Hi there,

I am trying to display information from Active Directory using a DataGrid.
Now, I know MS have put out the System.DirectoryServices classes to make this
easy. But if you just want to query and display, it seems an easier path is
to use the AdsDsoObject provider with OleDb, and get back a DataTable, pour
into a DataView, bind to the DataGrid, voila! At least, that's the theory.
The main driver is that trying to bind a SearchResultCollection to a DataGrid
doesn't yield very satisfactory results, and that's the only useful class in
the DirectoryServices namespace that implements ICollection and IEnumerable.

The problem is, if I manually construct a DataTable with dummy data, pour
into a DataView, bind to DataGrid and display then I see exactly what I would
expect.
If I setup an OleDbDataAdapter, query the AD, fill a DataSet and serialize
to XML I see what I would expect.
If I setup an OleDbDataAdapter, query the AD, fill a DataTable, pour into a
DataView, bind to the DataGrid and display, I get:
System.Web.HttpException: DataGrid with id '' could not automatically
generate any columns from the selected data source

Here is the source for Page_Load that generates the last result:

string ldapString =
"<LDAP://DC=acme,DC=com>;(&(objectClass=user)(objectCategor y=person));cn,distinguishedName;subtree";
string connstr = "Provider=ADsDSOObject;User
ID=acme\\Administrator;Password=notthispassword";
OleDbConnection conn = new OleDbConnection(connstr);
OleDbDataAdapter da = new OleDbDataAdapter(ldapString, conn);
DataTable dt = new DataTable("Table1");
da.Fill(dt);
DataView dv = new DataView(dt);
dg1.DataSource = dv;
dg1.DataBind();

Now, I'm fairly new to all this, but I've spent a good couple of days
butting up against this one. The only checking I haven't really done is
using OleDb with a different provider and seeing if it is a general problem.
The main reason I haven't done that is that I can see the data there if I use
an alternate means of accessing it! So, any ideas?

MTIA,

Mick Heywood
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Sequence.nextval numeric type in Oracle 10g differs from Oracle 8i when using MS OleDb provider alasdair.johnson@gmail.com ASP .Net 0 04-27-2007 04:57 PM
OLEDB Provider for SQL SERVER + Parameterized Queries Martin ASP .Net 2 03-16-2005 01:14 AM
Indexing Service (MSIDXS OLEDB Provider) Error - Impersonation Fai YK ASP .Net Security 0 10-13-2004 09:23 AM
.NET Framework 1.1 SP1 and MSIDXS OLEDB Provider YK ASP .Net Security 0 09-21-2004 07:07 AM
Data type question for OLEdb data types Brian Henry ASP .Net 1 10-05-2003 03:18 PM



Advertisments