[Mono-list] DbDataAdapter in ADO.NET Provider Factory

Daniel Morgan danmorg@sc.rr.com
Tue, 12 Nov 2002 05:06:08 -0500


Sounds cool!  I can't wait to get my hands on it.

Can we have the extremely lazy option too:

// create connection behind the scenes, create an adapter,
// fill a new data set via the adapter
// based on the configuration option
// (all this with one line of code)
DataSet ds = ProviderFactory.FillNewDataSetFromConfig ("TdsPubsConnStr",
"select * from author");

-----Original Message-----
From: mono-list-admin@ximian.com [mailto:mono-list-admin@ximian.com]On
Behalf Of Brian Ritchie
Sent: Tuesday, November 12, 2002 12:04 AM
To: danmorg@sc.rr.com; tim@timcoleman.com; rodrigo@ximian.com
Cc: mono-list@ximian.com
Subject: Re: [Mono-list] DbDataAdapter in ADO.NET Provider Factory


Daniel,

Thanks for reminding me about the DataAdapter...we wouldn't want Tim's hard
work to go to waste.  :-)

I've jacked in data adapter support.  I'm using the app.config to supply the
type names (instead of hard coding it in the factory).

Here's the syntax:

  // Create Connection
  IDbConnection conn =
ProviderFactory.CreateConnectionFromConfig("TdsPubsConnStr");

  // Select command
  IDbCommand cmd=conn.CreateCommand();
  cmd.Text="select * from author";

  // Data Adapter
  DataSet ds=new DataSet();
  IDbDataAdapter adapter=ProviderFactory.CreateDataAdapter(cmd);
  adapter.Fill(ds, "Table1");

-- or for the lazy among us :) --

  // Create Connection
  IDbConnection conn =
ProviderFactory.CreateConnectionFromConfig("TdsPubsConnStr");

  // Data Adapter
  DataSet ds=new DataSet();
  IDbDataAdapter adapter=ProviderFactory.CreateAdapter(conn, "select * from
author");
  adapter.Fill(ds, "Table1");

--- or for the super lazy among us (like me) ---

  // Create Connection
  IDbConnection conn =
ProviderFactory.CreateConnectionFromConfig("TdsPubsConnStr");

  // Data Adapter
  DataSet ds=DataTools.FillDataSet(conn, "select * from author");


Let me know if this will work for you.  I'm should have the code committed
this evening.  (I hope).

Brian