Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How could you use a DataRow rowfilt

Status
Not open for further replies.

jennyek2000

Programmer
Sep 2, 2003
43
GB
How could you use a DataRow rowfilter to filter out all of the records that have got a NULL value.
 
Jenny

There appears to be no easy way to do this with the datatable.select command.

You could write a code loop to do this, and iterate through each record in your datatable, and return a datarow collection

Or...why not disallow Nulls in your datatable. If you are creating the datatable, you could specify a default value for the column, eg Zero instead of Null.


WTrueman
...if it works dont mess with it
 
Hi Jenny
I wrote a function that does what u want
You can access the function
Dim MyRow as object
MyRow=GetRow(COLUMN_NAME,<value>)
Regards
Nouman

Public Function getRow(ByVal strColumnName As String, ByVal strColumnValue As String, ByVal dtBindedDataSet As DataTable) As Object
Try
Dim findRow() As DataRow
Dim strSql As String
If IsNumeric(strColumnValue) Then 'If its is digit
strSql = strColumnName & &quot; = '&quot; & Trim(strColumnValue) & &quot;'&quot;
Else
strSql = strColumnName & &quot; like '&quot; & Trim(strColumnValue) & &quot;%'&quot;
End If

findRow = dtBindedDataSet.Select(strSql)
If findRow.Length = 0 Then
getRow = Nothing
Else
getRow = findRow
End If
Catch exp As Exception
MsgBox(exp.Message, MsgBoxStyle.Information, &quot;Information&quot;)
End Try
End Function
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top