Skip to Main Content

DevOps, CI/CD and Automation

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Interested in getting your voice heard by members of the Developer Marketing team at Oracle? Check out this post for AppDev or this post for AI focus group information.

Create table using select statment using OLEDB in C# ASP.NET

993069Mar 14 2013 — edited Mar 24 2013
Hi,

I am trying ctreate a table on oracle database from front end C# ASP.NET using OLEDB connection.

But I am not able to create table using select statment.

Can anyone please help me out with this and let me know how can I create a table using select statement. Select statment is having mote than one column which need to be inserted into new table.

I am trying below code but its not at all working and I guess I am doing it wrong.

OleDbCommand sql = new OleDbCommand("Select CUSTOMER_CITY, CUSTOMER_STATE, Region from Karen_Provided_Excel", con);
try
{
if (con.State == ConnectionState.Closed)
{
con.Open();
OleDbDataReader objReader;
objReader = sql.ExecuteReader();

//string strTemp = "Name Varchar(30), Address Varchar(30)";
OleDbCommand myCommand = new OleDbCommand();
myCommand.Connection = con;
myCommand.CommandText = "CREATE TABLE Abhi_Test_DotNet(" + objReader.ToString() + ")";
myCommand.ExecuteNonQuery();
Label1.Text = "Table Created Successfully";
}

}


catch (Exception ex)
{
Label1.Text = "<br />ERROR WITH TEST METHOD: " + ex;
}

finally
{
if (con.State == ConnectionState.Open)
{
con.Close();

}

} ;

Thanks in adavnce for your help.

Regards,
Abhishek
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Apr 21 2013
Added on Mar 14 2013
5 comments
6,319 views