OleDbDataAdapter, Connection String Question?

G

Guest

My Question is this, I'm having trouble getting the OleDbDataAdapter to Point
to another connection string and pull the data out of the DataSet I created
from the Excel Spread Sheet and Place it up in a SQL table. I'm Sorry for the
mess of Code but I've been at this all Day now. If you have any Ideas I could
surely use the help.
Thank You,
Terry
string File = ofdExcel.FileName;
string sConn = @"Provider=Microsoft.Jet.OLEDB.4.0;" +
"Data Source="+File+@";" +
"Extended Properties=Excel 8.0;";
OleDbConnection DC =new OleDbConnection(sConn);
DC.Open();
OleDbCommand OC =new OleDbCommand("SELECT * FROM [Sheet1$]"",DC);
OleDbDataAdapter OA =new OleDbDataAdapter();
OA.SelectCommand=OC;
DataSet DS =new DataSet();
DataTable custTable = DS.Tables.Add("Global");
OA.Fill(DS,"Global");

//--> Clone the old DataSet and create new pointer to DS2
string Oconn = @"Integrated Security=SSPI;Packet Size=4096;Data
Source=""SomeSource"";Tag with column collation when
possible=False;Initial Catalog=IA;Use Procedure for Prepare=1;Auto
Translate=True;Persist Security

Info=False;Provider=""SQLOLEDB.1"";Workstation ID=TVIT13;Use Encryption for
Data=False";
OleDbConnection CO2 =new OleDbConnection(Oconn);
DataSet DS2 = new DataSet();
DS2 = DS.Clone(); //-->Clone DataSet
OleDbCommand OC2 = new OleDbCommand();
OleDbDataAdapter OA2 =new OleDbDataAdapter();

//The Problem is this, How can I get the Clone DataSet to Dump into a
OleDbDataAdapter and point it over to the new connection string to place into
the SQL Data Base??????

OA2.SelectCommand=OC2;
 
G

Guest

Hi Terry,

I have a similar requirement of reading large no.of rows from excel and
updating it into SQL tables. Have you found solution to your problem? please
help me.

Thanks
--Jay
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top