Solved

using AND in Dataview

Posted on 2013-06-10
2
181 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 51

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

On Demand Webinar - Networking for the Cloud Era

This webinar discusses:
-Common barriers companies experience when moving to the cloud
-How SD-WAN changes the way we look at networks
-Best practices customers should employ moving forward with cloud migration
-What happens behind the scenes of SteelConnect’s one-click button

Question has a verified solution.

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

Article by: Kraeven
Introduction Remote Share is a simple remote sharing tool, enabling you to see, add and remove remote or local shares. The application is written in VB.NET targeting the .NET framework 2.0. The source code and the compiled programs have been in…
If you're writing a .NET application to connect to an Access .mdb database and use pre-existing queries that require parameters, you've come to the right place! Let's say the pre-existing query(qryCust) in Access takes a Date as a parameter and l…
There's a multitude of different network monitoring solutions out there, and you're probably wondering what makes NetCrunch so special. It's completely agentless, but does let you create an agent, if you desire. It offers powerful scalability …
This is my first video review of Microsoft Bookings, I will be doing a part two with a bit more information, but wanted to get this out to you folks.

729 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