How to create database and table in sqlite program

2019-08-17 07:44发布

问题:

Can any body help me about, how to create simple database and tables programatically and insert values ,step by step procedure in sqlite using monotouch.I am new to this technology . Thank you..

回答1:

If you're using sqlite-net (which I highly recommend) you can simply call:

Model

public class Stock
{
        [PrimaryKey, AutoIncrement]
        public int Id { get; set; }
        [MaxLength(8)]
        public string Symbol { get; set; }
}

Create

var db = new SQLiteConnection("stocks.db");
db.CreateTable<Stock>();

Insert

var s = db.Insert(new Stock() {
Symbol = symbol });

Query

return db.Query ("select * from Valuation where StockId = ?", stock.Id);