Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
B

Bastar Media

@Bastar Media
About
Posts
13
Topics
2
Shares
0
Groups
0
Followers
0
Following
0

Posts

Recent Best Controversial

  • [SOLVED]: Not Getting Proper Output From Compiled EXE File
    B Bastar Media

    Ok dear, I will keep that in mind for my future projects.

    C# help visual-studio

  • [SOLVED]: Not Getting Proper Output From Compiled EXE File
    B Bastar Media

    Ok, I will keep that in mind for my future projects.

    C# help visual-studio

  • [SOLVED]: Not Getting Proper Output From Compiled EXE File
    B Bastar Media

    Hi Mika, Although I am getting the desired result, I know removing all disposed statements is not a perfect solution. Will you please help me to tell Where actually I should apply dispose statement. Regards.

    C# help visual-studio

  • [SOLVED]: Not Getting Proper Output From Compiled EXE File
    B Bastar Media

    Thanks a lot Mika, I found a solution. Actually the object SQLiteconnection was disposing and hence not giving the output while running from EXE, but this exception was not being catching while running from the IDE. I removed all the dispose statements in my project and not its running fine. And thanks a lot for you log file idea, it helped me a lot to detect the error.

    C# help visual-studio

  • [SOLVED]: Not Getting Proper Output From Compiled EXE File
    B Bastar Media

    Hi Mika, As you said I designed a logfile stream writer and now I got my log file full of these two errors:

    ERROR: Cannot access a disposed object.
    Object name: 'SQLiteConnection'. TARGET: Void CheckDisposed() STACK TRACE: at System.Data.SQLite.SQLiteConnection.CheckDisposed()
    at System.Data.SQLite.SQLiteConnection.get_State()
    at System.Data.SQLite.SQLiteDataReader.CheckClosed()
    at System.Data.SQLite.SQLiteDataReader.Read()
    at PTMS.Classes.Reports.Reporting.WardWiseTax(Int32 WardNumber) in Reporting.cs:line 209
    19/09/2015 12:18:39 PM : ERROR: Cannot access a disposed object.
    Object name: 'SQLiteConnection'. TARGET: Void CheckDisposed() STACK TRACE: at System.Data.SQLite.SQLiteConnection.CheckDisposed()
    at System.Data.SQLite.SQLiteConnection.get_State()
    at System.Data.SQLite.SQLiteDataReader.CheckClosed()
    at System.Data.SQLite.SQLiteDataReader.Read()
    at PTMS.Classes.Reports.Reporting.WardWiseTax(Int32 WardNumber, Boolean TotalPaid) in Reporting.cs:line 231

    And here is the code where I am getting those errors:

    private double WardWiseTax(Int32 WardNumber)
    {
    double TT = 0;
    try
    {
    Engine E = new Engine();
    SQLiteCommand CUSTCMD = new SQLiteCommand(E.SelectSQL("CUSTOMERS", "WARDNUMBER"), E.Conn);
    CUSTCMD.Parameters.AddWithValue("WARDNUMBER", WardNumber);
    SQLiteDataReader CUSTRDR = CUSTCMD.ExecuteReader();
    Calculate CT = new Calculate();

                while (CUSTRDR.Read()) // Here is the error (209)
                    TT += CT.LedgerBalance(CUSTRDR\["DEMAND"\].ToString())\[1\];
    
                CUSTCMD.Dispose();
                CUSTRDR.Dispose();
                CT.Dispose();
    
                return TT;
            }
            catch (Exception ex) { LogEvent.WriteErrorLog(ex); return 0; }
        }
        private double WardWiseTax(Int32 WardNumber, bool TotalPaid)
        {
            double TT = 0;
            try
            {
                Engine E = new Engine();
                SQLiteCommand CUSTCMD = new SQLiteCommand(E.SelectSQL("CUSTOMERS", "WARDNUMBER"), E.Conn);
                CUSTCMD.Parameters.AddWithValue("WARDNUMBER", WardNumber);
                SQLiteDataReader CUSTRDR = CUSTCMD.ExecuteReader();
                Calculate CT = new Calculate();
    
                while (CUSTRDR.Read()) // Here is the error (231)
                {
                    TT += CT.Le
    
    C# help visual-studio

  • [SOLVED]: Not Getting Proper Output From Compiled EXE File
    B Bastar Media

    Hi Gonzoox, Thanks for the reply. Yes, I had executed and executing the program from the same folder as it was created by the IDE. Moreover, debugging line by line, I am getting proper watch values on each variables. Even though, I will debug it once more as you said. Thanks.

    C# help visual-studio

  • [SOLVED]: Not Getting Proper Output From Compiled EXE File
    B Bastar Media

    Hi OriginalGriff, The code for input and output files is

    private static readonly string TemplatesFile =
    Path.Combine(Directories.CurrentDirectory, "Reports", "ReportsTemplate.xlsx");
    private static readonly string MastersFile =
    Path.Combine(Directories.CurrentDirectory, "Reports", "Master.xlsx");
    private static FileInfo Template = new FileInfo(TemplatesFile);
    private static FileInfo Masters;

    The folders have suitable permissions. Yes, Debug and Release version are on the same computer, under same user. When I run the EXE file I am not getting any output on both Debug and Release versions, but getting nice excel report when I run it from the IDE. I am getting no errors. But, in the output window of the IDE, I am getting lots of First Chance Exceptions like this:

    A first chance exception of type 'System.ObjectDisposedException' occurred in System.Data.SQLite.dll

    Even though, I am getting a nice excel report. But not from EXE file. Regards.

    C# help visual-studio

  • [SOLVED]: Not Getting Proper Output From Compiled EXE File
    B Bastar Media

    Hearty Sorry for not posting the code: Here is the code:

    public void WardList()
    {
    #region Load Values...
    int count = 1;
    List WWList = new List();
    Engine E = new Engine();
    SQLiteCommand CMD = new SQLiteCommand(E.SelectSQL("WARDS") + " ORDER BY [WARDNUMBER];", E.Conn);
    SQLiteDataReader RDR = CMD.ExecuteReader();

            while (RDR.Read())
            {
                WardWise WW = new WardWise();
                WW.Serial = count;
                WW.WardNumber = Convert.ToInt32(RDR\["WARDNUMBER"\]);
                WW.WardCount = WardCount(WW.WardNumber);
                WW.Name = RDR\["NAME"\].ToString();
                WW.Manager = RDR\["MANAGER"\].ToString();
                WW.TotalTax = WardExists(WW.WardNumber) ? WardWiseTax(WW.WardNumber) : 0;
                WW.TotalPaid = WardExists(WW.WardNumber) ? WardWiseTax(WW.WardNumber, false) : 0;
                WW.Balance = WW.TotalTax - WW.TotalPaid;
                count++;
                WWList.Add(WW);
            }
            #endregion
    
            using (ExcelPackage EP = new ExcelPackage(Masters, Template))
            {
                double hook = 8;
                ExcelWorksheet Sheet = EP.Workbook.Worksheets\["AWW"\];
    
                foreach (WardWise WW in WWList)
                {
                    Sheet.Cells\["A" + hook\].Value = WW.Serial;
                    Sheet.Cells\["B" + hook\].Value = WW.WardNumber + " \[" + WW.WardCount + "\]";
                    Sheet.Cells\["C" + hook\].Value = WW.Name;
                    Sheet.Cells\["D" + hook\].Value = WW.Manager;
                    Sheet.Cells\["E" + hook\].Value = WW.TotalTax;
                    Sheet.Cells\["F" + hook\].Value = WW.TotalPaid;
                    Sheet.Cells\["G" + hook\].Formula = ("E" + hook) + "-" + ("F" + hook);
                    hook++;
                }
                Sheet.Cells\["A8:G" + (hook - 1)\].Style.Border.Top.Style =
                    Sheet.Cells\["A8:G" + (hook - 1)\].Style.Border.Bottom.Style =
                    Sheet.Cells\["A8:G" + (hook - 1)\].Style.Border.Left.Style =
                    Sheet.Cells\["A8:G" + (hook - 1)\].Style.Border.Right.Style = ExcelBorderStyle.Thin;
    
                Sheet.Cells\["G" + (hook + 1)\].Formula = string.Format("SUM(G8:G{0})", hook - 1);
                Sheet.Cells\["G" + (hook + 1)\].Style.Font.Bold = true;
                Sheet.Cells\["G" + (hook + 1)\].Style.Border.Top.Style =
    
    C# help visual-studio

  • [SOLVED]: Not Getting Proper Output From Compiled EXE File
    B Bastar Media

    Hi GuyThiebaut, I tried that too, but getting no success.

    C# help visual-studio

  • [SOLVED]: Not Getting Proper Output From Compiled EXE File
    B Bastar Media

    Hearty Sorry, Here is the code:

    public void WardList()
    {
    #region Load Values...
    int count = 1;
    List WWList = new List();
    Engine E = new Engine();
    SQLiteCommand CMD = new SQLiteCommand(E.SelectSQL("WARDS") + " ORDER BY [WARDNUMBER];", E.Conn);
    SQLiteDataReader RDR = CMD.ExecuteReader();

            while (RDR.Read())
            {
                WardWise WW = new WardWise();
                WW.Serial = count;
                WW.WardNumber = Convert.ToInt32(RDR\["WARDNUMBER"\]);
                WW.WardCount = WardCount(WW.WardNumber);
                WW.Name = RDR\["NAME"\].ToString();
                WW.Manager = RDR\["MANAGER"\].ToString();
                WW.TotalTax = WardExists(WW.WardNumber) ? WardWiseTax(WW.WardNumber) : 0;
                WW.TotalPaid = WardExists(WW.WardNumber) ? WardWiseTax(WW.WardNumber, false) : 0;
                WW.Balance = WW.TotalTax - WW.TotalPaid;
                count++;
                WWList.Add(WW);
            }
            #endregion
    
            using (ExcelPackage EP = new ExcelPackage(Masters, Template))
            {
                double hook = 8;
                ExcelWorksheet Sheet = EP.Workbook.Worksheets\["AWW"\];
    
                foreach (WardWise WW in WWList)
                {
                    Sheet.Cells\["A" + hook\].Value = WW.Serial;
                    Sheet.Cells\["B" + hook\].Value = WW.WardNumber + " \[" + WW.WardCount + "\]";
                    Sheet.Cells\["C" + hook\].Value = WW.Name;
                    Sheet.Cells\["D" + hook\].Value = WW.Manager;
                    Sheet.Cells\["E" + hook\].Value = WW.TotalTax;
                    Sheet.Cells\["F" + hook\].Value = WW.TotalPaid;
                    Sheet.Cells\["G" + hook\].Formula = ("E" + hook) + "-" + ("F" + hook);
                    hook++;
                }
                Sheet.Cells\["A8:G" + (hook - 1)\].Style.Border.Top.Style =
                    Sheet.Cells\["A8:G" + (hook - 1)\].Style.Border.Bottom.Style =
                    Sheet.Cells\["A8:G" + (hook - 1)\].Style.Border.Left.Style =
                    Sheet.Cells\["A8:G" + (hook - 1)\].Style.Border.Right.Style = ExcelBorderStyle.Thin;
    
                Sheet.Cells\["G" + (hook + 1)\].Formula = string.Format("SUM(G8:G{0})", hook - 1);
                Sheet.Cells\["G" + (hook + 1)\].Style.Font.Bold = true;
                Sheet.Cells\["G" + (hook + 1)\].Style.Border.Top.Style =
                    Sheet.Cells\["G" + (h
    
    C# help visual-studio

  • [SOLVED]: Not Getting Proper Output From Compiled EXE File
    B Bastar Media

    Hello there, WORK: I am working on a project, in which the output of some methods create a excel sheet. PROBLEM: When I run the project from IDE, the excel file is created properly and with all data from List. But, when its run from the compiled EXE file, I am getting no output in the excel file. Please help.

    C# help visual-studio

  • Unable to work with Multi-Threading
    B Bastar Media

    Hello Friend, sorry for my long code and IniFile is not static. moreover, IniFile is not static. Here is the exception report: System.InvalidOperationException was unhandled by user code. Additional information: The calling thread cannot access this object because a different thread owns it. And the line where I am getting the code:

    var INF = new IniFile(Path.Combine(Directories.OLD_DATAFOLDER, @"yt.txn"));

    C# question help

  • Unable to work with Multi-Threading
    B Bastar Media

    Hello there, Please have a look in this code: ERROR LINE IS JUST BELOW #REGION YEARLYTAX... (COMMENTED)

    private void ImportData_MouseLeftButtonDown(object sender, MouseButtonEventArgs e)
    {
    #region Delete Previous Data...
    if (MessageBox.Show("Delete all previous records?", "DELETE ALL", MessageBoxButton.YesNo, MessageBoxImage.Question, MessageBoxResult.No) == MessageBoxResult.Yes)
    {
    if (MessageBox.Show("ALL RECORDS WILL BE DELETED PERMANENTLY... ARE YOU SURE?", "DELETE ALL", MessageBoxButton.YesNo, MessageBoxImage.Question, MessageBoxResult.No) == MessageBoxResult.Yes)
    {
    lblMessage.Content = "Please wait...";
    Cursor = Cursors.Wait;
    Engine E = new Engine();
    SQLiteCommand CMD = new SQLiteCommand("DELETE FROM YEARS", E.Conn);
    CMD.ExecuteNonQuery();
    CMD = new SQLiteCommand("DELETE FROM WARDS", E.Conn);
    CMD.ExecuteNonQuery();
    CMD = new SQLiteCommand("DELETE FROM USERS", E.Conn);
    CMD.ExecuteNonQuery();
    CMD = new SQLiteCommand("DELETE FROM SETTINGS", E.Conn);
    CMD.ExecuteNonQuery();

                    E.Dispose();
                    CMD.Dispose();
                    Cursor = null;
                }
                else goto Import;
            }
            #endregion
    
        Import:
            ButtonsPanel.IsEnabled = false;
            FrmClose.IsEnabled = false;
    
            BW.WorkerSupportsCancellation = false;
            BW.WorkerReportsProgress = true;
            BW.WorkerSupportsCancellation = false;
            BW.DoWork += BW\_DoWork;
            BW.ProgressChanged += BW\_ProgressChanged;
            BW.RunWorkerCompleted += BW\_RunWorkerCompleted;
            BW.RunWorkerAsync();
    
            lblMessage.Content = "Done...";
            ButtonsPanel.IsEnabled = true;
            FrmClose.IsEnabled = true;
        }
        void BW\_RunWorkerCompleted(object sender, RunWorkerCompletedEventArgs e)
        {
            lblMessage.Content = "Done...";
            Progress.Value = 0;
        }
        void BW\_ProgressChanged(object sender, ProgressChangedEventArgs e)
        {
            Progress.Value = e.ProgressPercentage;
        }
        void BW\_DoWork(object sender, DoWorkEventArgs e)
        {
            Progress.Value = 0;
    
    C# question help
  • Login

  • Don't have an account? Register

  • Login or register to search.
  • First post
    Last post
0
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups