Solved

using AND in Dataview

Posted on 2013-06-10
2
176 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 49

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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Microsoft Reports are based on a report definition, which is an XML file that describes data and layout for the report, with a different extension. You can create a client-side report definition language (*.rdlc) file with Visual Studio, and build g…
Creating an analog clock UserControl seems fairly straight forward.  It is, after all, essentially just a circle with several lines in it!  Two common approaches for rendering an analog clock typically involve either manually calculating points with…
Windows 10 is mostly good. However the one thing that annoys me is how many clicks you have to do to dial a VPN connection. You have to go to settings from the start menu, (2 clicks), Network and Internet (1 click), Click VPN (another click) then fi…
Internet Business Fax to Email Made Easy - With  eFax Corporate (http://www.enterprise.efax.com), you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, f…

864 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

24 Experts available now in Live!

Get 1:1 Help Now