Advertisement
Guest User

Untitled

a guest
Jan 15th, 2013
49
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 2.18 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Data.SQLite;
  6. using System.Data;
  7. using System.Reflection;
  8. using System.IO;
  9. namespace ADOConn
  10. {
  11.     public class DAO
  12.     {
  13.         private SQLiteConnection conn;
  14.         private SQLiteCommand comando;
  15.         private SQLiteDataAdapter dta;
  16.         private DataTable dt;
  17.         public string pasta;
  18.            
  19.         public DAO()
  20.         {
  21.             if (Directory.Exists("BD"))
  22.             {
  23.                 foreach (var fileDirectory in Directory.GetFiles("BD", "*.s3db"))
  24.                 {
  25.                     conn = new SQLiteConnection(string.Format("Data Source={0};", new FileInfo(fileDirectory).DirectoryName + fileDirectory));
  26.                     try
  27.                     {
  28.                     }
  29.                     catch (Exception)
  30.                     {
  31.                     }
  32.                 }
  33.             }
  34.             pasta = conn.ConnectionString;
  35.             comando = new SQLiteCommand();
  36.             comando.Connection = conn;
  37.  
  38.  
  39.             //conn = new SQLiteConnection(@"data source=C:\ProjetoSVN\ADOConn\BancoConfiguracao.s3db");
  40.             //comando = new SQLiteCommand();
  41.             //comando.Connection = conn;
  42.         }
  43.  
  44.         public void Insert(string texto)
  45.         {
  46.             comando.CommandText = texto;
  47.             conn.Open();
  48.             comando.ExecuteNonQuery();
  49.             conn.Close();
  50.         }
  51.  
  52.         public void Delete(string texto)
  53.         {
  54.             comando.CommandText = texto;
  55.             conn.Open();
  56.             comando.ExecuteNonQuery();
  57.             conn.Close();
  58.         }
  59.  
  60.         public void Update(string texto)
  61.         {
  62.             comando.CommandText = texto;
  63.             conn.Open();
  64.             comando.ExecuteNonQuery();
  65.             conn.Close();
  66.         }
  67.  
  68.         public DataTable Select(string texto)
  69.         {
  70.             dta = new SQLiteDataAdapter(comando);
  71.             dt = new DataTable();
  72.             comando.CommandText = texto;
  73.             conn.Open();
  74.             dt.Clear();
  75.             dta.Fill(dt);
  76.             conn.Close();
  77.             return dt;
  78.         }
  79.     }
  80. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement