Programmatically Create Oracle Typed DataSets?

  • Thread starter Thread starter Tim Smith
  • Start date Start date
T

Tim Smith

Hi,

Is it possible to create a progam to mimic the following action

a) drag oledbadapter to form1.cs
b) select my oracle ole connection
c) enter 'select * from mytable'
d) create adapter for select only (no updates)
e) repeat for all my tables
f) generate dataset for all the those adapters/tables

Doing by hand is going to be a little tedious for my 500 tables...
I need the typed dataset

thanks!

Tim
 
Tim,

Good news, it is actually possible.

One gotcha - all your typed datasets will have to map an equivalent SQL
Query/Table/Stored proc in your oracle database (not a big deal huh?).

OracleDataAdapter and OleDBDataAdapter (and SqlDataAdapter should u care
for) should have a FillSchema method on it, use that to cread XSD files,
then run XSD.EXE to create .cs or .vb files to generate strongly typed
datasets out of that.

One word of caution - donot use FillSchema in a production application, the
query that it executes is hella expensive. Pre-prepare your strongly typed
datasets to include in your app, don't generate them on the fly.

Hope that helps.

- Sahil Malik
Independent Consultant
You can reach me thru my blog at -
http://www.dotnetjunkies.com/weblog/sahilmalik/
 
If you already have the DataAdapters set up, you can use WriteXML from the
DataSet. You will have to be filling the same DataSet with all of the
adapters, of course.

Now, create a new DataSet object and copy the XML from the .xsd you created
with WriteXML. Then, you only need to change the DataSet declaration from
DataSet to your new name, like so:

DataSet DataSet1 = new DataSet();

MyStName DataSet1 = new DataSet();

There is no tool to do all of this, however. If you wanted to create a tool,
there is a table in oracle called ALL_ALL_TABLES to get table names. If you
want to figure out sprocs in the database, ALL_SOURCE is your baby. NOTE:
You will have to have perms to hit these tables.


--
Gregory A. Beamer
MVP; MCP: +I, SE, SD, DBA

************************************************
Think Outside the Box!
************************************************
 
Gregory,

I hope you mean WriteXML with the XmlMode = WriteSchema?? Just
clarifying/making sure/checking my own feet here. :)

Why not just DataAdapter.FillSchema then?

I agree with your assessment - there is no tool to do this directly, and
even for FillSchema to work, you need permissions to hit all those tables -
even in SQL Server.

- Sahil Malik
Independent Consultant
You can reach me thru my blog - http://dotnetjunkies.com/WebLog/sahilmalik/
 
I was shortcutting the idea, technically:

dataSet.WriteXMLSchema(fileName); //filename ends with .xsd

The import into the project can be done graphically in the IDE or in a text
editor by copying the XML.

I do like the other link you posted, BTW. Interesting code gen tool.

--
Gregory A. Beamer
MVP; MCP: +I, SE, SD, DBA

************************************************
Think Outside the Box!
************************************************
 
Back
Top