none
Create an Oracle Database from a Typed Dataset. RRS feed

  • Question

  •  

    Hi,

     

    I am currently working on a project where I have standard Data structures available. I have created a strongly typed dataset for it. My question is, Is it possible to automatically create (or generate) an oracle Database from a strongly typed dataset ?

     

    Please let me know in either case if its possible or not.

     

    Thanks in Advance for any help

     

    Regards

     

    Nasir

    Friday, August 8, 2008 8:17 AM

Answers

  • Hey Nasir,

     

    DataSet is a set of classes that are used disconnected from a Database. You can fill the DataTables in a DataSet with data from any type of database Oledb, ODBC, SqlClient, Oracle, or others.

     

    What I think you want here is you want to create a connection to a Oracle database. Then you need to create all the Oracle commands to create the relevant database, tables, columns and relationships.

     

    How would you go about doing this? Well if you were using Oracle and writing Sql queries to it how would you do these same operations. The only difference is that now you can write code and fill in the blanks based on the shape of the tables and relationships in the database.

     

    Here is some psuedo code

    //create connection to oracle db

    DbConnection oracleConnection = //Connection string stuff

    oracleConnection.Open();

    foreach(DataTable t in dataSet.Tables)

    {

    //Create a command to create a table

    string tableCommand = //Initial table create Sql Statement

    //Now add in the names of the columns into the create table

    foreach(DataColumn dc in t.Columns)

    {

    //You will need to map the primitive types in .net, int, decimal, double, etc to types in oracle, unsure of  specifics here

    }

    //Need to create relationships as well

    }

    oracleConnection.Close()

     

    What you could also do is create the database using Oracle GUI and then you could create the TableAdapters that are used to fill the data into your typed DataSet.

     

    Let me know if this helps.

     

    Thanks

    Chris Robinson

    Software Developer in Test - DataSet

    Friday, August 8, 2008 3:32 PM

All replies

  • Hey Nasir,

     

    DataSet is a set of classes that are used disconnected from a Database. You can fill the DataTables in a DataSet with data from any type of database Oledb, ODBC, SqlClient, Oracle, or others.

     

    What I think you want here is you want to create a connection to a Oracle database. Then you need to create all the Oracle commands to create the relevant database, tables, columns and relationships.

     

    How would you go about doing this? Well if you were using Oracle and writing Sql queries to it how would you do these same operations. The only difference is that now you can write code and fill in the blanks based on the shape of the tables and relationships in the database.

     

    Here is some psuedo code

    //create connection to oracle db

    DbConnection oracleConnection = //Connection string stuff

    oracleConnection.Open();

    foreach(DataTable t in dataSet.Tables)

    {

    //Create a command to create a table

    string tableCommand = //Initial table create Sql Statement

    //Now add in the names of the columns into the create table

    foreach(DataColumn dc in t.Columns)

    {

    //You will need to map the primitive types in .net, int, decimal, double, etc to types in oracle, unsure of  specifics here

    }

    //Need to create relationships as well

    }

    oracleConnection.Close()

     

    What you could also do is create the database using Oracle GUI and then you could create the TableAdapters that are used to fill the data into your typed DataSet.

     

    Let me know if this helps.

     

    Thanks

    Chris Robinson

    Software Developer in Test - DataSet

    Friday, August 8, 2008 3:32 PM
  • Hi Chris

     

    Thanks for the reply.

     

    This seems to involve a bit of workaround in terms of setting data types and relationships. I'll look into it. I'll look into it. seems like it will solve my problem.

     

    regards

     

    Nasir.

    Sunday, August 10, 2008 1:43 PM