1
Answer

OleDbConnection problem

j_sen21

j_sen21

16y
2.7k
1

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)