The example in this article describes a C # simple query SQLite database for data. Share to everyone for your reference, specific as follows:
SQLite Database Driver component
using System.Data.SQLite;
Insert Database function
int sqlquery (String sql)
{
try
{
//Open database
sqliteconnection conn = new Sqliteconnection ();
Sqliteconnectionstringbuilder connstr = new Sqliteconnectionstringbuilder ();
ConnStr. DataSource = "My.db";
Conn. ConnectionString = ConnStr. ToString ();
Conn. Open ();
Execute SQL statement
sqlitecommand cmd = new Sqlitecommand ();
Cmd.commandtext = SQL;
Cmd. Connection = conn;
Sqlitedatareader Reader=cmd. ExecuteReader ();
int result=0;
while (reader. Read ())
{
result=1;
}
Closes all connection
connstr. Clear ();
Conn. Close ();
return result;
}
catch (Exception ex)
{
//
} return
0;
}
Read more about C # Interested readers can view the site topics: "C # Programming Thread Usage Tips summary", "C # Operation Excel Skills Summary", "C # XML file Operation Tips Summary", "C # Common control usage Tutorial", "WinForm Control Usage Summary", "C # tutorial on data structure and algorithms, summary of C # array manipulation techniques, and an introductory course on C # object-oriented programming
I hope this article will help you with your C # programming.