locked
exception from hresult 0x800a03ec RRS feed

  • Question

  • User2031860760 posted

    hey guyzzzz plsss help me out if it is possible.....i m getting exception in d given below bold

    underlined line of code.....m new to asp.net...so plsss help me....i m attaching the whole code.....

    string MyConString = "SERVER=localhost;" +
                                  "DATABASE=cdac_web_team;" +
                                  "UID=root;" +
                                  "PASSWORD=mycomputer;";
    
    
           
                MySqlConnection myConnection = new MySqlConnection(MyConString);
                MySqlCommand myCommand = myConnection.CreateCommand();
                myCommand.CommandText = "SELECT * from garudaindia_feedback" ;
                MySqlDataReader myDataReader;
    
                Excel.Application xlApp;
                Excel.Workbook xlWorkBook;
                Excel.Worksheet xlWorkSheet;
                object misValue = System.Reflection.Missing.Value;
    
                xlApp = new Excel.ApplicationClass();
                xlWorkBook = xlApp.Workbooks.Add(misValue);
    
                xlWorkSheet = (Excel.Worksheet)xlWorkBook.Worksheets.get_Item(1);
             
                myConnection.Open();                     
                myDataReader = myCommand.ExecuteReader();
                myDataReader.Read();
                int i=1, j;
                if (myDataReader.HasRows)
                {          
                    while(myDataReader.Read())
                    {
                        j = 0;
                        xlWorkSheet.Cells[i, j++] = myDataReader.GetString("NAME");
                        xlWorkSheet.Cells[1, j++] = myDataReader.GetString("EMAIL");
                        xlWorkSheet.Cells[1, j++] = myDataReader.GetString("INST_ORG");
                        xlWorkSheet.Cells[1, j++] = myDataReader.GetString("SUBJECT");
                        xlWorkSheet.Cells[1, j++] = myDataReader.GetString("COMMENT");
                        i++;
                    }
                }
                myDataReader.Close();
                myConnection.Close();
                xlWorkBook.SaveCopyAs("C:\\csharp-Excel.xls");
                xlWorkBook.Close(true, misValue, misValue);
                xlApp.Quit();
                releaseObject(xlWorkSheet);
                releaseObject(xlWorkBook);
                releaseObject(xlApp);
            }
            private void releaseObject(object obj)
            {
                try
                {
                    System.Runtime.InteropServices.Marshal.ReleaseComObject(obj);
                    obj = null;
                }
                catch (Exception ex)
                {
                    obj = null;
                   // MessageBox.Show("Exception Occured while releasing object " + ex.ToString());
                }
                finally
                {
                    GC.Collect();
                }         
            }
    Friday, November 11, 2011 3:47 AM

Answers

  • User2031860760 posted

    i had solvd ma problm myself....i was starting the cell from 0 it sud start from 1.....hope it help others.....:):):)

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Friday, November 11, 2011 5:18 AM