DBInvador/DBHandler/SQLServerHandler.cs
/// <summary>
/// Get N number of records from given table
/// </summary>
/// <param name="tableName">Schema Qualified name of Table</param>
/// <param name="noOfRecords">Number of Records to Fetch</param>
/// <returns>DataTable of TOP N records from Given Table</returns>
Get N number of records from given table
Get N number of records from given table
public DataTable GetTableData(string dataBase, string tableName, int noOfRecords)
        {
            ConnectServer();
            ChangeDatabase(dataBase);
            DataSet DS = new DataSet();
            (new SqlDataAdapter("SELECT TOP " + noOfRecords.ToString() + " * FROM " + tableName, conn)).Fill(DS);
            conn.Close();
            return DS.Tables[0];
        }
public DataTable GetTableData ( string dataBase , string tableName , int noOfRecords ) { ConnectServer ( ) ; ChangeDatabase ( dataBase ) ; DataSet DS = new DataSet ( ) ; ( new SqlDataAdapter ( " " + noOfRecords . ToString ( ) + " " + tableName , conn ) ) . Fill ( DS ) ; conn . Close ( ) ; return DS . Tables [ 0 ] ; }
Get N number of records from given table
Get N number of records from given table
DataTable of TOP N records from Given Table
DataTable of TOP N records from Given Table
dataBase
string
tableName
string
Schema Qualified name of Table
Schema Qualified name of Table
noOfRecords
int
Number of Records to Fetch
Number of Records to Fetch