ExecuteReader() публичный Метод

执行一个查询语句,返回一个关联的SQLiteDataReader实例
public ExecuteReader ( string sql, SQLiteParameter parameters ) : SQLiteDataReader
sql string 要执行的查询语句
parameters System.Data.SQLite.SQLiteParameter 执行SQL查询语句所需要的参数,参数必须以它们在SQL语句中的顺序为准
Результат System.Data.SQLite.SQLiteDataReader
Пример #1
0
        static void ShowPassWord()
        {
            string dbPath = "E:\\data.db";
            //查询从50条起的20条记录
            string sql = "select PassWord  from t_user where UserCode = @UserCode";

            SQLiteParameter[] parameters = new SQLiteParameter[] {
                new SQLiteParameter("@UserCode", "zealfung0")
            };
            SqlLiteDBHelper db = new SqlLiteDBHelper(dbPath);

            using (SQLiteDataReader reader = db.ExecuteReader(sql, parameters))
            {
                while (reader.Read())
                {
                    Console.WriteLine("PSWD:{0}", reader.GetString(0));
                }
            }
        }
Пример #2
0
 static void ShowData()
 {
     try
     {
         string dbPath = "E:\\data.db";
         //查询从50条起的20条记录
         string          sql = "select * from t_user";
         SqlLiteDBHelper db  = new SqlLiteDBHelper(dbPath);
         using (SQLiteDataReader reader = db.ExecuteReader(sql, null))
         {
             while (reader.Read())
             {
                 Console.WriteLine("ID:{0},TypeName{1}", reader.GetString(0), reader.GetString(1));
             }
         }
     }
     catch (Exception ex)
     {
         Console.WriteLine("ShowData失败:" + ex.ToString());
     }
 }
Пример #3
0
 static void ShowPassWord()
 {
     string dbPath = "E:\\data.db";
     //查询从50条起的20条记录
     string sql = "select PassWord  from t_user where UserCode = @UserCode";
     SQLiteParameter[] parameters = new SQLiteParameter[]{
                                  new SQLiteParameter("@UserCode","zealfung0")
                                  };
     SqlLiteDBHelper db = new SqlLiteDBHelper(dbPath);
     using (SQLiteDataReader reader = db.ExecuteReader(sql, parameters))
     {
         while (reader.Read())
         {
             Console.WriteLine("PSWD:{0}", reader.GetString(0));
         }
     }
 }
Пример #4
0
 static void ShowData()
 {
     try
     {
         string dbPath = "E:\\data.db";
         //查询从50条起的20条记录
         string sql = "select * from t_user";
         SqlLiteDBHelper db = new SqlLiteDBHelper(dbPath);
         using (SQLiteDataReader reader = db.ExecuteReader(sql, null))
         {
             while (reader.Read())
             {
                 Console.WriteLine("ID:{0},TypeName{1}", reader.GetString(0), reader.GetString(1));
             }
         }
     }
     catch (Exception ex)
     {
         Console.WriteLine("ShowData失败:" + ex.ToString());
     }
 }