Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6039351
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T06:21:20+00:00 2026-05-23T06:21:20+00:00

I have a SQLite database that is displayed in a data grid view in

  • 0

I have a SQLite database that is displayed in a data grid view in my c# windows form. So, this database has four columns. My particular interest is in only one of the columns. The column indicates the type of message. It can be ERRORS or ALARMS or INITIALIZATION etc.. Now I have added functionality where the column can be edited and updated in the database.

Its like , I choose a list of ALARMS and then group them as ALARM # 1 (their type field is updated). Similarly ALARM # 2 and so on…

All this works fine. The problem is when I want to count the number of Alarms. I send a query

using(var sda=new SQLiteDataAdapter("SELECT count(*) from LogDatabase where Type like '%ALARM%'", "data source=" + database_path))
        {
            var dt = new DataTable();
            int sum_rows_selected=0;
            sda.Fill(dt);
            int alarms_total = Convert.ToInt16(dt.Rows[0][0]);
            MessageBox.Show(alarms_total.ToString());
        }

This shows all the fields with ALARM in it.. So, Initially if the DB had 10 rows of Type ALARMS. It shows 10 which is fine. But now when i edit 4 rows as ALARM # 1 and 5 rows as ALARM # 2.. I want the count to be 3 ( #1 as 1, #2 as 1 and rest of ALARMS (1 here) )…

I managed to get some weird logic to get the correct answer but this works only if the ALARMS are edited to #1 or #2 at that time. If i close the window and come back it doesnt work. It shows 10 again…

Help Please

Thanks

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-23T06:21:21+00:00Added an answer on May 23, 2026 at 6:21 am

    Try grouping them:
    Not sure if the syntax is different for SQLite, but something like

    SELECT Type, count(*) from LogDatabase where Type like '%ALARM%' Group by Type
    

    This should give you

    Alarm #1, 4
    Alarm #2, 5
    Alarm #5, 1
    

    My C# is rusty, but to get all the rows for both columns you would need a loop, or a data table, or a lot more variables. Forgive me if I botch up the syntax.

    string alarms_name[];
    int alarms_total[];
    int i;
    For(i=0;i < dt.Count; i++){
        alarms_name[i] = Convert.ToInt16(dt.Rows[i][0]);
        alarms_total[i] = Convert.ToInt16(dt.Rows[i][1]);
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a database that tracks players through their attempts at a game. To
My setup: I have a sqlite database from which I populate a NSMutableArray of
C# (.NET 3.5) I have an SQLite database with two tables - employees (the
[Note : I've simplified my example for clarity] Let's say that I have a
Python --> SQLite --> ASP.NET C# I am looking for an in memory database
I have an activity that extends ListView. I populate my list with the results
Hy! I'm trying for days now to create an application that receives GPS data
I have an Android application which talks to a public Data-API by calling URLs.
I have a datagridview which we will call dataGridViewExample. My object (the uncommon datatypes
Hello people I've been struggling to use sqlite in my C#2.0 application and I

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.