0

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

2
  • Kishore, please take the time to read the FAQ - stackoverflow.com/faq. You will get more useful help from people if you obey the rules for asking good questions. Specifically, you should take the time to ACCEPT answers to questions which are helpful to you. It appears that you have never done this for any of the previous questions you have posted. Commented Oct 31, 2011 at 13:04
  • Ok,but i didnt get solution from the previous answers.so i didnt accept those.Sory for that Commented Oct 31, 2011 at 14:51

1 Answer 1

3

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);

Sign up to request clarification or add additional context in comments.

1 Comment

Hi Anuj, so you know I use this solution, and the first time I run it in my emulator it goes very well, then I comment the code for creating the table (so it doesn't create it again), and when I run the project again it says that there´s no table in the DB. Do you know why is this?, do I need to create the DB every time I run the project? Thanxs.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.