关于Execl导入access的问题 我的目的是通过FileUpload控件或者其他的类似的控件能选择一个execl文件,然后读取此文件,通过datatable临时存储,最后存储到access数据库中我是新人,高手们帮帮忙吧~回答的时候最好附上代码,越详细越好谢谢啦~我会在线等的~ 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 使用DataSet读Excel代码见参考参考1参考2 把Excel数据读入到Dataset string strConnection = "Provider=Microsoft.ACE.OLEDB.12.0;"; strConnection += @"Data Source=C:\Documents and Settings\v-changl\My Documents\couse.xlsx;"; strConnection += "Extended Properties=\"Excel 12.0 Xml;HDR=YES\";"; OleDbConnection objConnection = new OleDbConnection(strConnection); objConnection.Open(); OleDbDataAdapter myCommandd = new OleDbDataAdapter("select * from [Sheet1$]", objConnection); DataSet ds = new DataSet(); myCommandd.Fill(ds, "[Sheet1$]"); System.Data.DataTable dt = ds.Tables["[Sheet1$]"]; Console.WriteLine(dt.Columns[0].ToString()); Console.WriteLine(dt.Columns[1].ToString()); 本文来自CSDN博客,转载请标明出处:http://blog.csdn.net/LCL_data/archive/2009/05/06/4154784.aspx Datase回冲到Access #region Access 2007 Console.WriteLine("Access 2007"); string strConnection = "Provider=Microsoft.ACE.OLEDB.12.0;"; strConnection += @"Data Source=C:\Documents and Settings\v-changl\My Documents\Database1.accdb;"; strConnection += "Persist Security Info=False"; using (OleDbConnection objConnection = new OleDbConnection(strConnection)) { objConnection.Open(); OleDbDataAdapter myCommandd = new OleDbDataAdapter("select * from Couse", objConnection); DataSet ds = new DataSet(); myCommandd.Fill(ds, "couse"); DataTable dt = ds.Tables["couse"]; Console.WriteLine(dt.Columns[0].ToString()); Console.WriteLine(dt.Columns[1].ToString()); Console.WriteLine(dt.Columns[2].ToString()); objConnection.Close(); } #endregion 本文来自CSDN博客,转载请标明出处:http://blog.csdn.net/LCL_data/archive/2009/05/06/4154255.aspx 楼上的好像是用控制台程序啊,能不能直接用web做个例子啊~人比较笨,谢谢啦~ 对CSS苦恼中!!! 为什么会经常出现死锁,怎么解决 Page中引入的一个JS,JS输入的内容成了乱码 求助;如何实现下图图片上传 400万数据,8400双核+4G内存,SQL2005+NET3.5,10万PV,CPU99%怎么处理? 运行超大的.SQL文件 切肤之痛,网站被黑了 建议:单独开设asp.net2.0讨论专区。 两个关于datagrid分页的问题 請問一些ASP的係統變量 这样删除数据为什么不行呢?急!马上要交任务了,谢谢啊,大家帮帮忙 web service 返回 XML格式数据
代码见参考
参考1
参考2
string strConnection = "Provider=Microsoft.ACE.OLEDB.12.0;";
strConnection += @"Data Source=C:\Documents and Settings\v-changl\My Documents\couse.xlsx;";
strConnection += "Extended Properties=\"Excel 12.0 Xml;HDR=YES\";";
OleDbConnection objConnection = new OleDbConnection(strConnection);
objConnection.Open();
OleDbDataAdapter myCommandd = new OleDbDataAdapter("select * from [Sheet1$]", objConnection);
DataSet ds = new DataSet();
myCommandd.Fill(ds, "[Sheet1$]");
System.Data.DataTable dt = ds.Tables["[Sheet1$]"];
Console.WriteLine(dt.Columns[0].ToString());
Console.WriteLine(dt.Columns[1].ToString()); 本文来自CSDN博客,转载请标明出处:http://blog.csdn.net/LCL_data/archive/2009/05/06/4154784.aspx
Console.WriteLine("Access 2007");
string strConnection = "Provider=Microsoft.ACE.OLEDB.12.0;";
strConnection += @"Data Source=C:\Documents and Settings\v-changl\My Documents\Database1.accdb;";
strConnection += "Persist Security Info=False";
using (OleDbConnection objConnection = new OleDbConnection(strConnection))
{
objConnection.Open();
OleDbDataAdapter myCommandd = new OleDbDataAdapter("select * from Couse", objConnection);
DataSet ds = new DataSet();
myCommandd.Fill(ds, "couse");
DataTable dt = ds.Tables["couse"];
Console.WriteLine(dt.Columns[0].ToString());
Console.WriteLine(dt.Columns[1].ToString());
Console.WriteLine(dt.Columns[2].ToString());
objConnection.Close();
}
#endregion
本文来自CSDN博客,转载请标明出处:http://blog.csdn.net/LCL_data/archive/2009/05/06/4154255.aspx
人比较笨,谢谢啦~