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

  • SEARCH
  • Home
  • 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 6131379
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T16:58:03+00:00 2026-05-23T16:58:03+00:00

I am new to c# and Database linking that’s why not able to get

  • 0

I am new to c# and Database linking that’s why not able to get this by searching old posts of stackoverflow

Code like

private void bookDetails()
    {
        string connectionPath = @"Data Source=Data\libraryData.dat;Version=3;New=False;Compress=True";

        using (SQLiteConnection connection = new SQLiteConnection(connectionPath))
        {
            SQLiteCommand command = connection.CreateCommand();
            connection.Open();
            string query = "SELECT bookno as 'Book No.', bookCode as 'ISBN No.', title as 'Title', author as 'Author', publisher as 'Publishers', edition as 'Edition', storagehint as 'Storage Hint', description as 'Description' FROM booksDetails";
            command.CommandText = query;
            command.ExecuteNonQuery();

            SQLiteDataAdapter da = new SQLiteDataAdapter(command);
            DataSet ds = new DataSet();
            da.Fill(ds, "booksDetails");
            int c = ds.Tables["booksDetails"].Rows.Count;
            dataGridView1.DataSource = ds.Tables["booksDetails"];
            dataGridView1.Sort(dataGridView1.Columns["ISBN No."], ListSortDirection.Ascending);
            dataGridView1.ReadOnly = true;
            connection.Close();
            this.Totals.Text = "Total No. of Books Found : "+ Convert.ToString(c);
        }
    }

i used like above for getting some library book details, now i want highlight a particular cell or change its color by the value of no. of book or any other..

sample code preferred

thanks in advance…

  • 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-23T16:58:04+00:00Added an answer on May 23, 2026 at 4:58 pm
    private void dataGridView1_CellFormatting(object sender, DataGridViewCellFormattingEventArgs e)
        {
            Color c = Color.Black;
            if (e.ColumnIndex == 6)
            {
                if (isLate(Convert.ToString(e.Value)))
                    c = Color.Red;
            }
            e.CellStyle.ForeColor = c; // or e.CellStyle.BackColor= c; whatever you can do like this
    
        }
    

    and code for event is

    this.dataGridView1.CellFormatting += new System.Windows.Forms.DataGridViewCellFormattingEventHandler(this.dataGridView1_CellFormatting);
    

    this will be auto generated in yourform.designer.cs or else you add it manually

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am new to c# and Database linking that's why not able to get
I am working on an old database, that i do not want to touch
We are designing a new database and I would like some input in where
I have an old database and a new database. The old records were converted
I created a new Entity Framework model from a database. This database has a
I'm designing a new DataBase that at the moment has 50 Tables. For many
I have a couple of POCO objects that look like this: public abstract class
Setting up a new database that has a comments table. I've been told to
I am building a multithreaded system that works like this: While there are entities:
Soooo, I am starting this new job soon where most of the code is

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.