SQLite

<< Click to Display Table of Contents >>

Navigation:  Outros >

SQLite

Previous pageReturn to chapter overviewNext page

Arquivos

 

sqlite3.exe
System.Data.SQLite.DLL

 

Código fonte

 
...
using System.Data.Common;
using System.Data.SQLite;
 
        
      ...
      
        private void Form1_Load(object sender, EventArgs e)
        {
            SQLiteConnection.CreateFile(@"d:\junior.db3");
            SQLiteConnection connection = new SQLiteConnection();
            connection.ConnectionString = @"Data Source=d:\junior.db3";
            connection.Open();
 
            SQLiteCommand command = new SQLiteCommand();
 
            command.Connection = connection;
            command.CommandText = "CREATE TABLE Contatos ([codigo] INTEGER PRIMARY KEY, [Nome] NVARCHAR(40), [Email] NVARCHAR(50))";
            command.ExecuteNonQuery();
            command.CommandText = "INSERT INTO Contatos (Nome,Email) VALUES('Junior',  'eu@tu.com.br')";
            command.ExecuteNonQuery();
            command.CommandText = "INSERT INTO Contatos (Nome,Email) VALUES('Macho',  'ele@tu.com.br')";
            command.ExecuteNonQuery();
            command.CommandText = "INSERT INTO Contatos (Nome,Email) VALUES('Outro',  'nós@tu.com.br')";
            command.ExecuteNonQuery();
            connection.Close();
       }