Exemplo n.º 1
0
 /// <summary>
 /// Create a reader from the supplied SQL statment. Execute
 /// the supplied delegate--a method that "borrows" the reader--
 /// and close the reader.
 /// </summary>
 /// <param name="sql">The SQL select statement to execute.</param>
 /// <param name="borrower">The method to call that uses a reader.</param>
 /// <returns>The supplied method's return value.</returns>
 public static object LendReader(string sql, BorrowReader borrower)
 {
     using (OleDbConnection conn = CreateConnection())
     {
         conn.Open();
         OleDbCommand    c = new OleDbCommand(sql, conn);
         OleDbDataReader r = c.ExecuteReader();
         return(borrower(r));
     }
 }
Exemplo n.º 2
0
 public static object LendReaderSQLConnection(string sql, BorrowReader borrower)
 {
     using (SqlConnection conn = CreateSqlConnection())
     {
         conn.Open();
         SqlCommand    c = new SqlCommand(sql, conn);
         SqlDataReader r = c.ExecuteReader();
         return(borrower(r));
     }
 }
Exemplo n.º 3
0
 // ... and Foo.Bar() is also generic
 public static T Bar <T>(BorrowReader <T> borrower)
 {