class myclass1 { public void doSomething { SQLiteConnection conn = new SQLiteConnection(myString); conn.Open(); SQLiteCommand cmd = new SQLiteCommand("someSqlStatement", conn); SQLiteDataReader reader = cmd.ExecuteReader(); //loop and do work. conn.close() } } class myclass2 { public void doSomethingElse {//get another connection again SQLiteConnection conn = new SQLiteConnection(myString); conn.Open(); SQLiteCommand cmd = new SQLiteCommand("someSqlStatement", conn); SQLiteDataReader reader = cmd.ExecuteReader(); //loop and do work. conn.close() } }
class myclass3 { public void doSomethingEasy {//use "globalConn" which was passed in the constructor SQLiteCommand cmd = new SQLiteCommand("someSqlStatement", globalConn); SQLiteDataReader reader = cmd.ExecuteReader(); //loop and do work. conn.close() } }
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)