Query Excel to DataGrid in VS. 2003


ตอบคำถามเพื่อนสมาชิก GF p’ Nano please help me http://greatfriends.biz?77616
Download Demo public_small WebAppQueryExcel_VS2003.zip

        private void Button1_Click(object sender, System.EventArgs e)
string path = Server.MapPath ("Book1.xls");
System.Data.OleDb.OleDbConnection conn = 
new OleDbConnection (@"Provider=Microsoft.Jet.OLEDB.4.0;Data Source=’"+path+"’; Extended Properties=’Excel 8.0;HDR=Yes;’;");

string sql = "Select * FROM [Sheet1$]";
DataSet ds = new DataSet ();
System.Data.OleDb.OleDbDataAdapter da = new OleDbDataAdapter(sql,conn);
da.Fill (ds);

            if (ds.Tables[0].Rows.Count >0)
DataGrid1.DataSource = ds;
DataGrid1.DataBind ();



Nuchit Atjanawat is a Microsoft MVP, GreatFriends Community Leader, WindowsITPro Columnist(Mr.Nano), Silverlight Business Application Instructor, Speaker in various Microsoft events, Author, passionate Blogger and a Software Engineer by profession. He has a very good skill over Silverlight, LightSwitch, C#, XAML & Blend. He shares his technical findings, tutorials in his technical blog. Follow his Blog and Facebook page to be updated on latest articles. - Technical Blog: https://janawat.wordpress.com - WindowsITPro Columnist(Mr.Nano): http://windowsitpro.net - The GreatFriends.Biz Community Discussion Board (nano): http://greatfriends.biz - witter: https://twitter.com/janawat - Facebook Page: https://www.facebook.com/nuchit - Instructor: http://bit.ly/GF250-01, http://bit.ly/GF150-02

เขียนใน Web Application


Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  เปลี่ยนแปลง )

Google+ photo

You are commenting using your Google+ account. Log Out /  เปลี่ยนแปลง )

Twitter picture

You are commenting using your Twitter account. Log Out /  เปลี่ยนแปลง )

Facebook photo

You are commenting using your Facebook account. Log Out /  เปลี่ยนแปลง )


Connecting to %s

In Archive
%d bloggers like this: