Follow along with the video below to see how to install our site as a web app on your home screen.
Note: This feature may not be available in some browsers.
using(IDbConnection connection = new SqlConnection())
{
foreach(DataRow row in table.Rows)
{
int id = (int)row.["id"];
if(id > 0 && id <= 10)
{
using(IDbCommand command = connection.CreateCommand())
{
command.CommandText = "delete from [table] where [id] = @id";
IDbParameter parameter = command.CreateParameter("id");
parameter.Value = id;
command.Parameters.Add(parameter);
command.ExecuteNonQuery();
}
}
}
}
using(IDbConnection connection = new SqlConnection())
using(IDbCommand command = connection.CreateCommand())
{
command.CommandText = "delete from [table] where [id] between @floor and @ceiling";
IDbParameter floor = command.CreateParameter("floor");
floor.Value = 1;
command.Parameters.Add(floor);
IDbParameter ceiling = command.CreateParameter("ceiling");
ceiling.Value = 10;
command.Parameters.Add(ceiling);
command.ExecuteNonQuery();
}
foreach (DataRow row in myDataTable.Rows)
{
int id = (int)row["RowNum"];
oLog.EnterEventLog("After", System.Diagnostics.EventLogEntryType.FailureAudit);
if (id < _StartRow && id > _EndRow)
{
row.Delete();
}
}
private void RemoveRowsForPaging (DataTable myDataTable)
{
AddRowNumColumn(myDataTable);
foreach (DataRow row in myDataTable.Rows)
{
int id = (int)row["RowNum"];
if (id < _StartRow || id > _EndRow)
{
row.Delete();
}
}
}
private void AddRowNumColumn(DataTable myDataTable)
{
// Initialize DataColumn
DataColumn RowNum = new DataColumn();
// Add First DataColumn
// AllowDBNull property
RowNum.AllowDBNull = false;
// set AutoIncrement property to true
RowNum.AutoIncrement = true;
// set AutoIncrementSeed property equal to 1
RowNum.AutoIncrementSeed = 1;
// set AutoIncrementStep property equal to 1
RowNum.AutoIncrementStep = 1;
// set ColumnName property to specify the column name
RowNum.ColumnName = "RowNum";
// set DataType property of the column as Integer
RowNum.DataType = System.Type.GetType("System.Int32");
// set Unique property of DataColumn to true to allow unqiue value for this column in each row
//RowNum.Unique = true;
// Add and Create a first DataColumn
myDataTable.Columns.Add(RowNum);
int i = 1;
foreach (DataRow row in myDataTable.Rows)
{
row["RowNum"] = i;
i++;
}
}
public DataTable FilterTable(DataTable table, int floor, int ceiling)
{
DataTable results = new DataTable();
results.Schema = table.GetSchema(); //not 100% on this
for(int i=0; i<table.Rows.Count; i++)
{
if(floor < id && id <= ceiling )
results.AddRow(table.Rows[i].ItemArray);
}
return results;
}