Esempio n. 1
0
 /// <summary>
 /// 插入数 据
 /// </summary>
 /// <param name="sdata"></param>
 /// <param name="scn"></param>
 private static void InsertData(SQliteData sdata, SQLiteConnection scn)
 {
     if (scn.State != ConnectionState.Open)
     {
         scn.Open();
         SQLiteCommand cmd = scn.CreateCommand();
         cmd.Connection  = scn;
         cmd.CommandText = string.Format("insert into t1 values({0},{1},{2},{3})", sdata.Id, sdata.Indata, sdata.Strdata, sdata.Iamgeinfo);
         cmd.ExecuteNonQuery();
         scn.Close();
     }
 }
Esempio n. 2
0
 /// <summary>
 /// 查找数据
 /// </summary>
 /// <param name="sdata"></param>
 /// <param name="scn"></param>
 private static void SelectData(SQliteData sdata, SQLiteConnection scn)
 {
     if (scn.State != ConnectionState.Open)
     {
         scn.Open();
         SQLiteCommand cmd = scn.CreateCommand();
         cmd.Connection  = scn;
         cmd.CommandText = "select* from t1 where imageinfo=770";
         SQLiteDataReader sr = cmd.ExecuteReader();
         while (sr.Read())
         {
             Console.WriteLine("Indata:" + sr.GetValue(1));
         }
         sr.Close();
         cmd.ExecuteNonQuery();
         scn.Close();
     }
 }
Esempio n. 3
0
        static void Main(string[] args)
        {
            string path = @"d:\123.db";

            CreateSQliteTable(path);
            ReaderGivenSQliteTable(path, "t1");
            //   ReaderAllSQliteTable(path);

            SQLiteConnection scn = new SQLiteConnection("data source=" + path);

            for (int i = 0; i < 1; i++)
            {
                SQliteData sdata = new SQliteData("34", i, "78", DateTime.Now.Millisecond.ToString());
                //    InsertData(sdata, scn);
                SelectData(sdata, scn);
            }
            Console.WriteLine("结束");
            Console.Read();
        }