Create and update excel file

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • farnena
    New Member
    • Nov 2009
    • 3

    Create and update excel file

    I want to create a excel file every month and update details on certain events in a web application.

    1. I dunno how to create Excel file in Web environment.
    2. When I was trying to update the existing excel file its throwing error.

    ERROR: Syntax error in INSERT INTO

    Code:
     string connectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=FEB_LOG.xls;Extended Properties='Excel 8.0;HDR=YES;'";
            OleDbConnection objConn = new OleDbConnection(connectionString);
            OleDbCommand objCommand = new OleDbCommand();
            objCommand.Connection = objConn;
            objCommand.CommandText = "INSERT INTO [Sheet1$] (CLAIMNO,DETAILS,DATE,STATUS,ERRORMESSAGE) VALUES (strClmNo,strDetails,Date,strstatus,strErrMsg)";
            OleDbParameter dbparmClmNo = new OleDbParameter("@strClmNo", strClmNo);
            OleDbParameter dbparmDetails = new OleDbParameter("@strDetails", strDetails);
            OleDbParameter dbparmDate = new OleDbParameter("@Date", DateTime.Now.ToShortDateString());
            OleDbParameter dbparmstatus = new OleDbParameter("@strstatus", strstatus);
            OleDbParameter dbparmErrMsg = new OleDbParameter("@strErrMsg", strErrMsg);
            objCommand.Parameters.Add(dbparmClmNo);
            objCommand.Parameters.Add(dbparmDetails);
            objCommand.Parameters.Add(dbparmDate);
            objCommand.Parameters.Add(dbparmstatus);
            objCommand.Parameters.Add(dbparmErrMsg);
            objConn.Open();
            objCommand.ExecuteNonQuery();
            objConn.Close();
    Last edited by tlhintoq; Mar 11 '10, 03:48 PM. Reason: [CODE] ...Your code goes between code tags [/CODE]
  • tlhintoq
    Recognized Expert Specialist
    • Mar 2008
    • 3532

    #2
    TIP: When you are writing your question, there is a button on the tool bar that wraps the [code] tags around your copy/pasted code. It helps a bunch. Its the button with a '#' on it. More on tags. They're cool. Check'em out.

    Comment

    Working...