Solved

using AND in Dataview

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

Simplifying Server Workload Migrations

This use case outlines the migration challenges that organizations face and how the Acronis AnyData Engine supports physical-to-physical (P2P), physical-to-virtual (P2V), virtual to physical (V2P), and cross-virtual (V2V) migration scenarios to address these challenges.

Question has a verified solution.

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

Well, all of us have seen the multiple EXCEL.EXE's in task manager that won't die even if you call the .close, .dispose methods. Try this method to kill any excels in memory. You can copy the kill function to create a check function and replace the …
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…
Established in 1997, Technology Architects has become one of the most reputable technology solutions companies in the country. TA have been providing businesses with cost effective state-of-the-art solutions and unparalleled service that is designed…
The Email Laundry PDF encryption service allows companies to send confidential encrypted  emails to anybody. The PDF document can also contain attachments that are embedded in the encrypted PDF. The password is randomly generated by The Email Laundr…

776 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