i want to access the cells of excel sheet in .NET c# as we do in case of oracle database. is there any code to convert xl data to oracle.please reply as early as possible.
Loading
i want to access the cells of excel sheet in .NET c# as we do in case of oracle database. is there any code to convert xl data to oracle.please reply as early as possible.
Know the answer? Post it. Somebody with the same question will find it here.
Answer a question in the forums and earn +20 SHARP for every answer.
See unanswered questions
DevSocialUpcoming · 3rd editionAI Agents ConferenceDec 1–3, 2026Live onlineFree to attend5days leftRegister
Sateesh ArvetiRank #96 · 22.3K reputationPosted Mar 20, 2009, 1:14 AM EDT
You can use either Excel Interop library or oledb provider to read excel data.After reading the data into a datareader,loop through it and insert into oracle table as shown below:
string ConnectionString = @"Provider=Microsoft.Jet.OLEDB.4.0; Data Source=C:\spreadsheet.xls; Extended Properties=""Excel 8.0;";
string CommandText = "select * from [sheetName]";
OleDbConnection myConnection = new OleDbConnection(ConnectionString);
OleDbCommand myCommand = new OleDbCommand(CommandText, myConnection);
myConnection.Open();
OleDbDataReader reader = myCommand.ExecuteReader(CommandBehavior.CloseConnection);
while (reader.Read())
{
//name =reader[0].ToString();
//Oracle Insert stmt here with values got from reader object.
}
Bechir BejaouiRank #144 · 15.9K reputationPosted Mar 20, 2009, 2:44 AM EDT
You want to access an Excel file
or
Transfer data from excel to oracle by using insert into SQL request
Vijaya KadiyalaRank #1,085 · 1.8K reputationPosted Mar 21, 2009, 8:48 AM EDT
Hi
You want to read the data from excel or insert the data into Oracle?
Thanks -- Vijaya Kadiyala
http://dotnetvj.blogspot.com
shruti balapgol5 reputationPosted Mar 22, 2009, 5:14 AM EDT
Bechir BejaouiRank #144 · 15.9K reputationPosted Apr 3, 2009, 2:18 AM EDT
shruti balapgol5 reputationPosted Apr 6, 2009, 3:20 AM EDT
thankyou so much
this code has solved my problem
string
connectionString1 = "Dsn=scott;uid=system;pwd=query";System.Data.Odbc.
OdbcConnection con = new System.Data.Odbc.OdbcConnection(connectionString1);System.Data.
DataSet dsOracle = new System.Data.DataSet(); string ConnectionString = @"Provider=Microsoft.Jet.OLEDB.4.0; " + "Data Source=" + "C:\\TBL_STUD_EMP_REC.xls" + ";" + "Extended Properties='Excel" + " 8.0;HDR=NO;IMEX=1;'"; string CommandText = "select * from [sheet1$]"; OleDbConnection myConnection = new OleDbConnection(ConnectionString); OleDbCommand myCommand = new OleDbCommand(CommandText, myConnection);myConnection.Open();
OleDbDataReader reader = myCommand.ExecuteReader(CommandBehavior.CloseConnection); while (reader.Read()){
System.
Console.WriteLine(reader[0].ToString()); string query = "INSERT INTO SCOTT.TBLSTUDEMPREC values('" + reader[0].ToString() + "','" + reader[1].ToString() + "','" + reader[2].ToString() + "')"; //'" + reader[3].ToString() + "')"; //values(2,'rini','pune')";con.Open();
System.Data.Odbc.
OdbcCommand cmd = new System.Data.Odbc.OdbcCommand(query, con);System.Data.Odbc.
OdbcDataAdapter adpt = new System.Data.Odbc.OdbcDataAdapter(cmd);adpt.Fill(dsOracle);
con.Close();
}
Bechir BejaouiRank #144 · 15.9K reputationPosted May 4, 2009, 2:37 AM EDT
Not at all you're welcome ; )
Bechir BejaouiRank #144 · 15.9K reputationPosted May 4, 2009, 2:37 AM EDT
Not at all you're welcome ; )
Bechir BejaouiRank #144 · 15.9K reputationPosted May 4, 2009, 2:37 AM EDT
Not at all you're welcome ; )