Databases Reference
In-Depth Information
End While
Me.dataSet.Tables.Add(table)
Me.dataView = New FCLData.DataView(table)
End If
End Sub
Assuming that the table name is valid and all of the requested fields are valid, you will use the temp
table you have built to satisfy data access requirements. The only thing left to do is add the new table to
the existing data set.
You have now validated all the parts of your query except the filtering and sorting criteria. In the
CommandText method you test whether filtering and sorting are enabled based upon your keyword
count. If they are enabled, you execute a method that uses the internal behavior of the DataSet class to do
the work. In the ValidateFiltering method, you need to parse out the text based upon the keyword
count. You either need to grab all of the text after the Where clause, or if an order clause exists, you need
to stop there.
C#
public void ValidateFiltering(string cmdText)
{
if(filtering)
{
StringBuilder sbFilterText = new StringBuilder();
int startPos =0;
int length =0;
startPos = (kwc[wherePosition].Index + kwc[wherePosition].Length+1);
if(keyWordCount ==3) //no “order by” - Search from Where till end
{
length = cmdText.Length-startPos;
}
else // “order by” exists - search from where position to “order by”
{
length = kwc[orderPosition].Index - startPos;
}
sbFilterText.Append(cmdText.Substring(startPos,length));
this.dataView.RowFilter = sbFilterText.ToString();
}
}
VB.NET
Private Sub ValidateFiltering(ByVal cmdText As String)
If filtering Then
Dim sbFilterText As StringBuilder = New StringBuilder
Dim startPos As Integer = 0
Dim length As Integer = 0
startPos = (kwc(wherePosition).Index + kwc(wherePosition).Length + 1)
If keyWordCount = 3 Then
length = cmdText.Length - startPos
Search WWH ::




Custom Search