unity3d 使用sqlite数据库

   //创建数据库名称为xuanyusong.db
  DbAccess db = new DbAccess("data source=horsegame.db");
  try{
   print("fdsfgdgdsafgdsagda");
   //请注意 插入字符串是 已经要加上'宣雨松' 不然会报错
   //db.CreateTable("datainfo",new string[]{"name","equipNo","colorType","status","scores"}, new string[]{"TEXT","INTEGER","INTEGER","INTEGER","TEXT"});
//   db.InsertInto("datainfo", new string[]{ "'equip1'","0","1","1","200"  });
//   db.InsertInto("datainfo", new string[]{ "'equip2'","0","0","1","400"  });  
   //注解1
   //SqliteDataReader sqReader = db.SelectWhere("datainfo",new string[]{"name","colorType"},new string[]{"equipNo"},new string[]{"="},new string[]{"0"});
   SqliteDataReader sqReader = db.ReadFullTable("datainfo");
   string strVal;
   int nVal;
   int i = 0;
   while (sqReader.Read())  
      { 
         Debug.Log(sqReader.GetString(sqReader.GetOrdinal("name")) + sqReader.GetString(sqReader.GetOrdinal("scores"))); 
       pro = new Property();
    nVal = sqReader.GetInt32(sqReader.GetOrdinal("equipNo"));
    pro.m_nEno = nVal;
    nVal = sqReader.GetInt32(sqReader.GetOrdinal("colorType"));
    pro.m_colorType = (ColorType)nVal;
    nVal = sqReader.GetInt32(sqReader.GetOrdinal("status"));
    pro.m_bStatu = nVal;
    strVal = sqReader.GetString(sqReader.GetOrdinal("scores"));
    m_score = System.Convert.ToInt32(strVal);
    AddEquipProperty(strEquipName[i], pro);
    ++i;
   } 
   
   db.CloseSqlConnection();
  }
  catch(SqliteException e){
   db.CloseSqlConnection();
  }


 

你可能感兴趣的:(Unity3D,C/C++/C#)