Skip to content

OleDbConnection problem

j_sen21

Asked Jan 11, 2008, 9:45 AM EST1 answer
Share
LinkedInX

Hello,

Im connecting to an excel spreadsheet that looks like this:

LEVEL     VALUE

None            0

Some          1.2

More           3

I create a data set:

Code
System.Data.DataSet ds = new System.Data.DataSet();
then I fill it.
cmd = new System.Data.OleDb.OleDbDataAdapter("select * from [Sheet1$]", cn);
cn.Open();
cmd.Fill(ds);
cn.Close();

Then:::::::::::::::::::::::::::::::::::

 

 

Java
DataTable tbl = ds.Tables[0];
for (int i = 0; i < tbl.Rows.Count; i++)
{
DataRow myRow = tbl.Rows[i];
string name = (string)myRow["LEVEL"];
double values = (double)myRow["VALUE"];


}
------------The problem-----------------------

Its getting the new string value of name for each row, but its returning 0 for each values row.

I tried to change values from a double to a text column in excel, it still said your bringing in a double.

HELPLPPPPPPPPPPPPPP!

Thanks

1 Answer

Know the answer? Post it. Somebody with the same question will find it here.

  • 0
    Can you plz also post the section of code where the OleDbConnection variable is instatiated / initialized?

    I didn't see it in the code you gave us and if that piece wasn't set up correctly then your adapter would not be able to fill the DataSet because you have no actual connection.

    Although this may not even be the problem, I just don't want to "check the hardware before I determine if it's plugged in." ;)
    0