Solved

using AND in Dataview

Posted on 2013-06-10
2
175 Views
Last Modified: 2013-06-10
Public Shared Function IsMatchRecordForDelete(dt As DataTable, description As String, titleid As String) As Boolean
        Try

            Dim datatable = DataTableCloneClass.ClonedDataTable(dt)
            Dim dview As DataView
            dview = datatable.DefaultView
            dview.RowFilter = "TitleID= '" + titleid + "'" And
                              "Description= '" + ChangeCaseClass.ToRemoveExtraSpaces(description) + "'"
            If (dview.Count > VariableClass.DefaultPrimaryKey) Then
                Return True
            Else
                Return False
            End If
        Catch ex As Exception
            ErrorHandlerClass.LogMessage(ex.Message + ex.StackTrace)
            Throw
        End Try
    End Function

Open in new window


When I execute the above function I get an error Conversion from string "TitleID= '3'" to type 'Long' is not valid.
0
Comment
Question by:GRChandrashekar
2 Comments
 
LVL 48

Expert Comment

by:Rgonzo1971
ID: 39234282
Hi

Maybe

      dview.RowFilter = "TitleID= '" + ChangeCaseClass.ToRemoveExtraSpaces(Convert.ToInt32(titleid)) + "'" +" And " +
                              "Description= '" + ChangeCaseClass.ToRemoveExtraSpaces(description) + "'"

Open in new window

0
 
LVL 42

Accepted Solution

by:
sedgwick earned 500 total points
ID: 39234286
using String.Format will makes it easier:
  dview.RowFilter = String.Format("TitleID = '{0}' and Description = '{1}'", Convert.ToInt32(ChangeCaseClass.ToRemoveExtraSpaces(titleid)), ChangeCaseClass.ToRemoveExtraSpaces(description))

Open in new window

0

Featured Post

Threat Intelligence Starter Resources

Integrating threat intelligence can be challenging, and not all companies are ready. These resources can help you build awareness and prepare for defense.

Join & Write a Comment

Calculating holidays and working days is a function that is often needed yet it is not one found within the Framework. This article presents one approach to building a working-day calculator for use in .NET.
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…
This video explains how to create simple products associated to Magento configurable product and offers fast way of their generation with Store Manager for Magento tool.

706 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

20 Experts available now in Live!

Get 1:1 Help Now