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!

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

thatJeffSmith-Oracle

it is being auto-adjusted...the true content is all that html, it's only that the GREEN is the only text being rendered
So in your query, easy to fix, adjust to column name width

User_AOUZ4

Hi Jeff,
Understood that rendering is causing the column width to be longer than expected.
how to adjust column name width . do you mean instead of column name "STATUS"
we should use "=============STATUS=============" or something like that ?

thatJeffSmith-Oracle
Answer

right click on headers, autofit on the header

Marked as Answer by User_AOUZ4 · Nov 24 2021
1 - 3
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,336 views