j_sen21

j_sen21

  • NA
  • 57
  • 0

OleDbConnection problem

Jan 11 2008 2:45 PM

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:

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:::::::::::::::::::::::::::::::::::

 

 

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

 


Answers (1)