Solved

using AND in Dataview

Posted on 2013-06-10
2
182 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 52

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

Creating Instructional Tutorials  

For Any Use & On Any Platform

Contextual Guidance at the moment of need helps your employees/users adopt software o& achieve even the most complex tasks instantly. Boost knowledge retention, software adoption & employee engagement with easy solution.

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…
It’s quite interesting for me as I worked with Excel using vb.net for some time. Here are some topics which I know want to share with others whom this might help. First of all if you are working with Excel then you need to Download the Following …
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.
Visualize your data even better in Access queries. Given a date and a value, this lesson shows how to compare that value with the previous value, calculate the difference, and display a circle if the value is the same, an up triangle if it increased…

623 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