问大家一个问题:在Excel中有一个单元格是日期数据,我输入的明明是2006-7-15(打开excel也能看到它),但使用Ms OldDB读取的是2002-8-14,怎么
public partial class test_test : System.Web.UI.Page
{
OleDbConnection connOleDb;
protected void Page_Load(object sender, EventArgs e)
{
DataTable tblData = new DataTable();
DataSet ds = new DataSet();
string lFilePath = "E:/Projects/Caesar/a.xls ";
string connectionstring = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source= "+lFilePath+ ";Extended Properties= 'Excel 8.0;HDR=Yes;IMEX=1 ' ";
try
{
// Open the connection to the Excel document, and select the data from the first worksheet
connOleDb = new OleDbConnection(connectionstring);
connOleDb.Open();
OleDbDataAdapter da = new OleDbDataAdapter(@ "SELECT * FROM [a, Payroll Report$] ", connOleDb);
da.Fill(ds, "TableDate ");
tblData = ds.Tables[ "TableDate "];
DateTime dt = DateTime.Now;
city_hours.DataSource = tblData;
city_hours.DataBind();
}
catch (Exception ex)
{
string c_errorMessage = ex.Message + " <br /> <br /> ";
}
finally
{
connOleDb.Close();
}
}
}
<%@ Page Language= "C# " AutoEventWireup= "true " CodeFile= "test