asp.net ʵÏÖexcelµ¼Èëµ½Êý¾Ý¿â
//ExcelÅúÁ¿µ¼Èëµ½Êý¾Ý¿â
protected void btnUpload_Click(object sender, EventArgs e)
{
string IsXls = System.IO.Path.GetExtension(UploadExcel.FileName.ToString().ToLower());
if (IsXls != ".xls")
{
Page.ClientScript.RegisterStartupScript(Page.GetType(), "", "<script type='text/javascript' language='javascript'>alert('Ö»¿ÉÒÔÑ¡ÔñExcelÎļþ');location.href='EmployeeAddPage.aspx';</script>");
return;//µ±Ñ¡ÔñµÄ²»ÊÇExcelÎļþʱ,·µ»Ø
}
string filePath = UploadExcel.PostedFile.FileName;
string fileName = UploadExcel.FileName;
DataSet ds = ExecleDs (filePath,fileName);
CommonLayer.employeeModel model = new CommonLayer.employeeModel();
DataAcessLayer.employee_infomation addlist = new DataAcessLayer.employee_infomation();
if (ds.Tables[0].Rows.Count > 0)
{
int row = ds.Tables[0].Rows.Count-1;
for (int i = 0; i < ds.Tables[0].Select().Length; i++)
{
&
Ïà¹ØÎĵµ£º
ÔÚASP.NetÒ»°ãµÄ³ÌÐò±àдÖУ¬ËùʹÓõÄÊý¾ÝÀïÃ棬ÈÕÆÚʱ¼äÊÇÒ»ÖÖÌØÊâµÄÊý¾ÝÀàÐÍ£¬Ò²ÊǾ³£±»Ê¹Óõġ£---µçÄԽ̳̼¼ÊõѧϰÍø
ÔÚVisual Basic.NETÖеÄÈÕÆÚʱ¼äÊý¾ÝÓÃÊýÖµµÄÊý¾ÝÀàÐͱ£´æ£¬¶øÇÒÓз¶Î§¡£
ÈÕÆڵķ¶Î§Êǹ«Ôª1Äê1ÔÂ1ÈÕ¡«¹«Ôª9999Äê1 2ÔÂ3 1ÈÕ£¬Ê±¼äµÄ·¶Î§ÊÇ00£º00£º00¡«23£º59£º59¡£ÉùÃ÷¸ñÊ½È ......
1.Êý¾ÝÁ¬½Ó·½Ê½
ASP.NET±¾ÉíµÄÊý¾Ý·ÃÎÊADO.NET²»Ö§³Ö¶ÔÓÚMySqlµÄÁ¬½ÓºÍ²éѯ£¬µ«ÊÇMySQL¹ÙÍøÉϾùÌṩÁ˶àÖÖASP.NETÁ¬½Óµ½MySQLµÄ·½Ê½£º
£¨1£©ODBCÇý¶¯µÄ·ÃÎÊ·½Ê½£ºmysql-connector-odbc-5.1.5-win32.msi£¬ODBC
£¨2£©ADO.NET¶ÔÓÚMySQLµÄ·ÃÎÊ·½Ê½£ºmysql-connector-net-6.2.2.zip
¸öÈËÑ¡ÓõÄÊǵڶþÖÖ£¬¸Ð¾õ·½±ã£¬ºÍ.NET¶ÔS ......
protected void Page_Load(object sender, EventArgs e)
{
/*
sql½Å±¾-´´½¨Ñ§Éú±í
create table student(id int,name varchar(50))
......
asp.netÉú³É¾²Ì¬Ò³Ãæͨ³£»áÓÐ2Öз½Ê½£¬Ò»ÖÖÊÇα¾²Ì¬£¬Ò»ÖÖÊÇÊÂÏÈдºÃÄ£°åÈ»ºóÖ±½ÓÌæ»»ÄÚÈÝ¡£¶ÔÓÚ2ÖÖ·½Ê½µÄÓÅȱµã£¬Ôڴ˲»ÌÖÂÛ£¬ÖصãÊÇ˵ϵڶþÖÖ·½Ê½£¬ÔÚÉú³É¾²Ì¬Ò³ÃæÖÐÓÐһЩÐÅÏ¢ÐèҪʵʱ´ÓÊý¾Ý¿â¶ÁÈ¡£¨±ÈÈ磺ÔÚÐÂÎÅÒ³Ã棬ÎÒÃÇ»áÐèҪһЩÈȵãÅÅÐУ¬ÕâЩÈȵãÐÂÎÅÎÒÃǾÍÐèҪʵʱµÄ´ÓÊý¾Ý¿âÀï±ßÄõ½£©¡£
......