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 8529951
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T09:08:47+00:00 2026-06-11T09:08:47+00:00

I am semi-new to C# but in particular using Sqlite within C#, currently I

  • 0

I am semi-new to C# but in particular using Sqlite within C#, currently I have a SQlite DB setup fine in terms of it connects with the application well I am running windows form application and I have bound a table within the database to a datagrid view.

This is all fine I have a function setup to run queries where i pass the SQL statement as a string to the function and it runs it as a query.

I was wandering how I do I get a result back from the query I know obviosuly it will be somthing like

private string QueryResult(string query){
    connect
    run query
    read query 
    return result
}

All th examples I have seen use Sqlreader but I can’t seem to get it work, I am really used to using PHP with SQL and that seems so much simpler than using it in C# can someone explain or point out somewhere I might be able to find a tutuorial or function that you can run any query in by passing it as a string and getting the result returned pretty simply? The results I need wont be arrays or huge things I am only looking to return 1 word strings or numbers at a time so I don’t need anything complicated.

Please help me out I spent about 4 hours reading about this stuff last night and didn’t seem to get anywhere.

  • 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-06-11T09:08:48+00:00Added an answer on June 11, 2026 at 9:08 am

    Try this, maybe it will help you:

    public string QueryResult(string query)
    {
        string result = "";
        SQLiteConnection sqlite = new SQLiteConnection("Data Source=/path/to/file.db");
        try
        {
            sqlite.Open();  //Initiate connection to the db
            SQLiteCommand cmd = sqlite.CreateCommand();
            cmd.CommandText = query;  //set the passed query
            result = cmd.ExecuteScalar().ToString();
        }
        finally
        {
            sqlite.Close();
        }
        return result;
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a semi-comprehensive KO setup. But so far I have only used KO
I have a script that executes database queries, and I use semi-colons + new
I'm building a semi-elaborate RadGrid where within my NestedViewTemplate I want to have a
I'm semi-new to writing ASP.Net applications using master pages and I've run into an
Sorry for the semi-generic title, but I'm still pretty new at rails and couldn't
I'm writing an application for the iPhone that communicates with a SQLite database but
I'm semi-new to android. I've been looking all over the internet, but I can't
I'm quite new to using PHP but this has been stumping me for a
I have just started studying Android, I have limited java knowledge but am semi
I'm using semi-transparent PNGs (due to the designer's overlapping of elements) and trying to

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.