[Mono-devel-list] Implementing custom data provider

Alan Tam Tam at SiuLung.com
Fri Mar 14 00:52:29 EST 2003


Dear Aleksey,

> This code works fine alas result XML doesn't have columns and looks like
> this
>
> <Users>
> <User />
> <User />
> </Users>

I seem to get a bit confused. Can you state clearly what you expect to get and
what you actually got?

I have touched the XMLDataDocument a bit a few days ago. So I may know
something.

Regards,
Alan

----- Original Message -----
From: "Aleksey Sudakov" <zander at objectstorm.net>
To: <mono-devel-list at lists.ximian.com>
Sent: Friday, March 14, 2003 4:07 AM
Subject: [Mono-devel-list] Implementing custom data provider


> Hello,
>
> This is not really related to Mono, but since you guys implemented so many
> custom data providers that I use as a reference I guess I ask anyway. I am
> using .NET for development and later would hope to just recompile on Mono,
> so everything bellow is about .NET.
>
> I am implementing custom data provider and I hit a problem I couldn't figure
> out. Here is a snippet of a code that shows how I use the adapter to fill
> dataset:
>
> MOPConnection myConnection = new
> MOPConnection("e://zander/2.0/c#/MOP/model.xml");
> MOPCommand myCommand = new MOPCommand(new QuerySpec("User", null),
> myConnection);
>
> MOPDataAdapter myAdapter = new MOPDataAdapter(myCommand);
> myAdapter.TableMappings.Add("Table", "User");
>
> DataSet ds = new DataSet("Users");
> myAdapter.Fill(ds);
> ds.WriteXml(Console.Out);
>
> This code works fine alas result XML doesn't have columns and looks like
> this
>
> <Users>
> <User />
> <User />
> </Users>
>
> I figured I am missing automatic schema generation during
> myAdapter.Fill(ds); so I added:
>
> myAdapter.MissingSchemaAction = MissingSchemaAction.Add;
>
> right before myAdapter.Fill(ds); and although this suppose (or may be I am
> missing something here???) to add schema information to the dataset without
> constraints... well it doesn't and MOPDataReader.GetSchemaTable() is never
> called.
>
> So instead of MissingSchemaAction.Add I used MissingSchemaAction.AddWithKey
> and this time  GetSchemaTable method got called, but althought my DataReader
> for every column sets IsUnique and IsKey to false in GetSchemaTable()  I am
> getting "Failed to enable constraints. One or more rows contain values
> violating non-null, unique, or foreign-key constraints."
>
> My questions are:
> 1. Why DbDataAdapter with MissingSchemaAction set to MissingSchemaAction.Add
> never calls GetSchemaTable on a DataReader?
>
> 2. Why I am getting an exception even though I don't have any constraints
> set when I set MissingSchemaAction to MissingSchemaAction.AddWithKey?
>
> 3. What columns should I set to true in DataReader.GetSchemaTable() to
> properly enable primary key constraints in MissingSchemaAction.AddWithKey
> scenario?
>
> Any hints would be greately appreciated,
> Aleksey
>
> _______________________________________________
> Mono-devel-list mailing list
> Mono-devel-list at lists.ximian.com
> http://lists.ximian.com/mailman/listinfo/mono-devel-list
>




More information about the Mono-devel-list mailing list