adding a dataset to Oracle database in C#
645940Jun 24 2008 — edited Jun 24 2008Hello,
I am reading a dataset from .csv files and now I want to write this dataset to an oracle database. I want to create these datatables in the database and every time after that the tables should be only updated. I started with open the oracle connection but I am not sure how to proceed further. Any ideas?
Thanks
Code:
public void Write(DataSet ds, string[] names)
{
string conStr = "User d=***;Password=***;DataSource=***";
Console.WriteLine("Exporting to datatable {0} ...", names[0]);
OracleConnection oraConnection = new OracleConnection(conStr);
try
{
oraConnection.Open();
Console.WriteLine("\nHello, Oracle Here!\n");
Console.WriteLine("Connection String: ");
Console.WriteLine(oraConnection.ConnectionString.ToString() + "\n");
Console.WriteLine("Current Connection State: ");
Console.WriteLine(oraConnection.State.ToString() + "\n");
Console.WriteLine("Oracle Database Server Version: ");
Console.WriteLine(oraConnection.ServerVersion.ToString());
}
catch (Exception ex)
{
Console.WriteLine("Error occured: " + ex.Message);
}
// create the command object
OracleCommand command = new OracleCommand(conStr);
foreach (DataTable table in ds.Tables)
{
.........
.........