SoFunction
Updated on 2025-03-02

C# simple method to query whether data exists in SQLite database

This article describes the method of C# to simply query whether data exists in SQLite database. Share it for your reference, as follows:

//sqlite database driver componentusing ;
//Insert the database function  int SQLquery(string sql)
  {
   try
   {
    //Open the database    SQLiteConnection conn = new SQLiteConnection();
    SQLiteConnectionStringBuilder connstr = new SQLiteConnectionStringBuilder();
     = "";
     = ();
    ();
    //Execute SQL statement    SQLiteCommand cmd = new SQLiteCommand();
     = sql;
     = conn;
    SQLiteDataReader reader=();
    int result=0;
    while (())
    {
     result=1;
    }
    //Close all connections    ();
    ();
    return result;
   }
   catch (Exception ex)
   {
        //
   }
   return 0;
}

For more information about C#, please visit the special topic of this site:Summary of thread usage techniques for C# programming》、《Summary of C# operation skills》、《Summary of XML file operation skills in C#》、《Tutorial on the usage of common C# controls》、《Summary of WinForm control usage》、《C# data structure and algorithm tutorial》、《Summary of C# array operation skills"and"Introduction to C# object-oriented programming tutorial

I hope this article will be helpful to everyone's C# programming.