[Mono-devel-list] Implementing custom data provider
Aleksey Sudakov
zander at objectstorm.net
Thu Mar 13 15:07:10 EST 2003
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
More information about the Mono-devel-list
mailing list