using System; using System.Web.UI; using System.Web.UI.WebControls; using System.Web.UI.WebControls.WebParts; using Microsoft.Office.Interop.Excel; using Microsoft.SharePoint; using Microsoft.SharePoint.Client; namespace test.VisualWebPart1 { public partial class VisualWebPart1UserControl : UserControl { protected void Page_Load(object sender, EventArgs e) { error.Text = ""; } protected void Button1_Click(object sender, EventArgs e) { try { System.Data.OleDb.OleDbConnection MyConnection; System.Data.OleDb.OleDbCommand myCommand = new System.Data.OleDb.OleDbCommand(); string sql = null; MyConnection = new System.Data.OleDb.OleDbConnection("Provider=Microsoft.ACE.OLEDB.12.0;Data Source='//eccoe-sps2010:9001/test1/Forms/AllItems.aspx';Extended Properties=Excel 12.0 Xml;"); string date = DateTime.Today.ToShortDateString(); MyConnection.Open(); myCommand.Connection = MyConnection; sql = "Insert into [S1$] ([DATE]) values('" + date + "')"; myCommand.CommandText = sql; myCommand.ExecuteNonQuery(); MyConnection.Close(); } catch (Exception ex) { error.Text = ex.Message; } } } }
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)