如何使用monotouch以编程方式在sqlite中创建数据库和表?

How to create database and table in sqlite programatically using monotouch?(如何使用monotouch以编程方式在sqlite中创建数据库和表?)
本文介绍了如何使用monotouch以编程方式在sqlite中创建数据库和表?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

问题描述

任何机构都可以帮助我,如何使用monotouch在sqlite中以编程方式创建简单的数据库和表并插入值,一步一步的过程.我是这项技术的新手.谢谢..

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..

推荐答案

如果您使用的是 sqlite-net(我强烈推荐)你可以简单地调用:

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

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

创建

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

插入

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

查询

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

Query

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

这篇关于如何使用monotouch以编程方式在sqlite中创建数据库和表?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

本站部分内容来源互联网,如果有图片或者内容侵犯了您的权益,请联系我们,我们会在确认后第一时间进行删除!

相关文档推荐

What does SQL clause quot;GROUP BY 1quot; mean?(SQL 子句“GROUP BY 1是什么意思?意思是?)
How to select the first row for each group in MySQL?(如何在MySQL中为每个组选择第一行?)
MySQL - Fetching lowest value(MySQL - 获取最低值)
Add and link mysql libraries in a cmakelist.txt(在 cmakelist.txt 中添加和链接 mysql 库)
What is a good database design (schema) for a attendance database?(考勤数据库的良好数据库设计(架构)是什么?)
Table relationship for subtypes(子类型的表关系)