A
ad
I use the code below to load a Excel into dataset:
I
he data in Excel is all number, and the field type of dataset is treat as
float field.
How can I treat them as string?
//-------------------------------------------------------------------------------------
DataSet ds = new DataSet();
string sConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;" + "Data
Source=" + savePath +
"; Extended Properties=" +
(char)34 + "Excel 8.0;IMEX=1;" + (char)34;
string sSelect = "SELECT * FROM [Data$]";
OleDbConnection objConn = new OleDbConnection(sConnectionString);
objConn.Open();
OleDbCommand objCmdSelect = new OleDbCommand(sSelect, objConn);
OleDbDataAdapter objAdapter1 = new OleDbDataAdapter();
objAdapter1.SelectCommand = objCmdSelect;
objAdapter1.Fill(ds, "XLData");
objConn.Close();
I
he data in Excel is all number, and the field type of dataset is treat as
float field.
How can I treat them as string?
//-------------------------------------------------------------------------------------
DataSet ds = new DataSet();
string sConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;" + "Data
Source=" + savePath +
"; Extended Properties=" +
(char)34 + "Excel 8.0;IMEX=1;" + (char)34;
string sSelect = "SELECT * FROM [Data$]";
OleDbConnection objConn = new OleDbConnection(sConnectionString);
objConn.Open();
OleDbCommand objCmdSelect = new OleDbCommand(sSelect, objConn);
OleDbDataAdapter objAdapter1 = new OleDbDataAdapter();
objAdapter1.SelectCommand = objCmdSelect;
objAdapter1.Fill(ds, "XLData");
objConn.Close();