Do a C # friend of a Get dataset function, not familiar with C #, collation, understand how to use
When mounting a table, use
public static DataSet Query (string SQLString) { using (sqliteconnection connection = new Sqliteconnection ( connectionString)) { DataSet ds = new DataSet (); Try { connection. Open (); Sqlitedataadapter command = new Sqlitedataadapter (SQLString, connection); Command. Fill (ds, "DS"); } catch (System.Data.SQLite.SQLiteException ex) { throw new Exception (ex. Message); } return DS; Returned a DataSet } }
Application:
When mounting a form, use it directly.
Grd.datasource=query (SQL). Tables[0]
Execute query statement, return sqlitedatareader//get return value with//</summary>// <param name= "strSQL" > Query statement </param > //<returns>SQLiteDataReader</returns> public static Sqlitedatareader ExecuteReader ( String strSQL) { sqliteconnection connection = new Sqliteconnection (connectionString); Sqlitecommand cmd = new Sqlitecommand (strSQL, connection); Try { connection. Open (); Sqlitedatareader myreader = cmd. ExecuteReader (); return myreader; } catch (System.Data.SQLite.SQLiteException e) { throw new Exception (e.message); } }
Application
Sqlitedatareader sqldr = dbsqlite.executereader (sql); Sqlitedatareader needs to be quoted first, using System.Data.SQLite; try { while (Sqldr.read ()) { int rn = SQLDR.GETINT32 (1); String Rname=sqldr.getvalue (0). ToString (); Field Read if (rn = = 5) { //if (rname). Equals ("1")) //{ // str + = Sqldr.getvalue (2). ToString () + "yes" + "\ r \ n"; } //else { // str + = Sqldr.getvalue (2). ToString () + "no" + "\ r \ n"; } } }catch { }