trunk/src/LythumOSL.Core/Data/Sql.cs
/// <summary>
/// Function returns few select results 
/// from for example stored procedure
/// as DataSet tables
/// </summary>
/// <param name="sql"></param>
/// <param name="closeConnection"></param>
/// <returns></returns>
Function returns few select results
from for example stored procedure
as DataSet tables
Function returns few select results from for example stored procedure as DataSet tables
public DataSet QueryDataSet (string sql, bool closeConnection)
		{
#warning todo: not tested, but must work
			Debug.Print ("Sql::Query: " + sql);
			Validation.RequireValidString (sql, "sql");
			Error ();
			_LastSql = sql;
			DataSet retVal = new DataSet ("D");
			IDbCommand cmd = CreateCommand (true);
			if (cmd != null)
			{
				try
				{
					cmd.CommandText = sql;
					IDataReader reader = cmd.ExecuteReader ();
					int tableNumber = 1;
					do
					{
						LythumDataTable t = new LythumDataTable (
							"T" + tableNumber.ToString ());
						t.Load (reader);
						retVal.Tables.Add (t);
						tableNumber++;
					}
					while (!reader.IsClosed);
				}
				catch (Exception ex)
				{
					Error (ex);
					if (_ThrowException)
						throw new LythumException ("LythumOSL.Core.Data.Sql.Query [ " + _LastSql + " ]", ex);
				}
				finally
				{
					cmd.Dispose ();
					if (closeConnection && !IsTransactionInProgress)
					{
						Close ();
					}
				}
			}
			return retVal;
		}
public DataSet QueryDataSet ( string sql , bool closeConnection ) { warning  todo: not tested, but must work Debug . Print ( " " + sql ) ; Validation . RequireValidString ( sql , " " ) ; Error ( ) ; _LastSql = sql ; DataSet retVal = new DataSet ( " " ) ; IDbCommand cmd = CreateCommand ( true ) ; if ( cmd != null ) { try { cmd . CommandText = sql ; IDataReader reader = cmd . ExecuteReader ( ) ; int tableNumber = 1 ; do { LythumDataTable t = new LythumDataTable ( " " + tableNumber . ToString ( ) ) ; t . Load ( reader ) ; retVal . Tables . Add ( t ) ; tableNumber ++ ; } while ( ! reader . IsClosed ) ; } catch ( Exception ex ) { Error ( ex ) ; if ( _ThrowException ) throw new LythumException ( " " + _LastSql + " " , ex ) ; } finally { cmd . Dispose ( ) ; if ( closeConnection && ! IsTransactionInProgress ) { Close ( ) ; } } } return retVal ; }
Function returns few select results
from for example stored procedure
as DataSet tables
Function returns few select results from for example stored procedure as DataSet tables
// throw exception if it enabled
None
sql
string
None
closeConnection
bool
None