Created
November 16, 2009 20:47
-
-
Save benmills/236296 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
using System.Data; | |
using System.Configuration; | |
using System.Linq; | |
using System.Web; | |
using System.Web.Security; | |
using System.Web.UI; | |
using System.Web.UI.HtmlControls; | |
using System.Web.UI.WebControls; | |
using System.Web.UI.WebControls.WebParts; | |
using System.Xml.Linq; | |
using System.Data.SqlClient; | |
using System.Data.SQLite; | |
using System.Collections.Generic; | |
namespace SimpleApp { | |
public class DataLayer { | |
private SQLiteConnection connection; | |
public DataLayer(string connection_string) { | |
this.connection = new SQLiteConnection(connection_string); | |
} | |
public List<Language> get_languages() { | |
string sql = "select name, id from langs"; | |
SQLiteCommand command = new SQLiteCommand(sql, this.connection); | |
SQLiteDataAdapter adapter = new SQLiteDataAdapter(command); | |
DataSet data = new DataSet(); | |
DataTable data_table = new DataTable(); | |
adapter.Fill(data, "id"); | |
data_table = data.Tables["id"]; | |
List<Language> langs = new List<Language>(); | |
foreach (DataRow row in data_table.Rows) { | |
langs.Add(new Language(Convert.ToInt32(row.ItemArray[1]), row.ItemArray[0].ToString())); | |
} | |
return langs; | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment