?
Solved

Missing operand before 'And' operator

Posted on 2006-11-27
4
Medium Priority
?
1,791 Views
Last Modified: 2008-02-01
Hi,
  I have the following method , I am using a active filter to return the fields which are active . I am getting the following error. I wonder if you can fix the error. I will post the method , please look in to that.

Error Message : Syntax error: Missing operand before 'And' operator.
I am getting the above error at the following line in the below method.

 AlarmModification.RowFilter = FilterStr.



 Function GetAlarmSet() As DataView
        Dim AlarmConn As SqlConnection
        Dim AlarmAdapter As SqlDataAdapter
        Dim AlarmSet As New DataSet()
        Dim QueryString As String
        'Dim AlarmView As DataView
        Dim FilterStr As String = String.Empty

        QueryString = "select a.alarm_ID , a.Description, a.mode,a.active, a.regulatory_alarm, a.auto_acknowledge," & _
                        " b.UNIT_ID as unitid" & _
                        " from Alarm_Definition a,  Unit b where a.unit_Id=b.UNIT_ID "
        AlarmConn = New SqlConnection(ConfigurationManager.ConnectionStrings("CMSConnStr").ConnectionString)
        Try
            'Load Alarm record Table
            AlarmAdapter = New SqlDataAdapter(QueryString, AlarmConn)
            AlarmAdapter.Fill(AlarmSet, "AlarmDefinition")
        Catch ex As Exception
            Dim errorMsg As String = ex.Message & " :Exception Inside AlarmModification.GetAlarmSet()"
            'Check if an exception occured while logging to the database
            'Initially store the errorMsg in the CLogger property
            CLogger.LogDB = "N"
            CLogger.CustomErrorMsg = errorMsg
            If CLogger.WriteLogMsg(errorMsg, "E") Then
                CLogger.LogDB = "Y"
            End If
            Throw New Exception(errorMsg)
        Finally
            If AlarmConn.State = ConnectionState.Open Then
                AlarmConn.Close()
            End If
        End Try
        'Get the Filter String
        FilterStr = FormFilterStr()
        AlarmModification = New DataView(AlarmSet.Tables("AlarmDefinition"))

        AlarmModification.RowFilter = FilterStr
        'AlarmModification.Sort = ViewState("sortField") & " " & ViewState("sortDirection")

        Return AlarmModification
    End Function
 

Thanks,

Sreekanth Nagabandi.
0
Comment
Question by:Sreekanth_Nagabandi
[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
  • 2
4 Comments
 
LVL 143

Expert Comment

by:Guy Hengel [angelIII / a3]
ID: 18019709
can you show us what the function FormFilterStr() returns?
0
 

Author Comment

by:Sreekanth_Nagabandi
ID: 18021358
Hi,

  The form filterString returns the following values.


Return Value captured during debugging:-   and unitid in (1,2,3,4,5,6,7,8)

I will post you the method.



''' <summary>
    ''' Method to form filter string based on the selected tree node and dropdown filters
    ''' </summary>
    ''' <returns>Filter String</returns>
    ''' <remarks></remarks>
    Protected Function FormFilterStr() As String
        Dim FilterStr As String
        Dim strFilter As String = String.Empty

        If Not MACTTree Is Nothing Then
            If Not MACTTree.SelectedNode Is Nothing Then
                strFilter = SelectTreeNode(MACTTree)
            End If
        End If
        If StrComp(ActiveFilter.SelectedValue, " ", CompareMethod.Text) = 0 Then
            'FilterStr = ACKFilter.SelectedValue
            'ElseIf StrComp(ACKFilter.SelectedValue, " ", CompareMethod.Text) = 0 Then
            FilterStr = ActiveFilter.SelectedValue
        Else
            'FilterStr = ActiveFilter.SelectedValue & " and " & ACKFilter.SelectedValue
        End If
        Session("SelectedActiveFilter") = ActiveFilter.SelectedIndex
        'Session("SelectedACKFilter") = ACKFilter.SelectedIndex
        'Adding TreeNode Filter to the Active and Acknowledge filters list
        If strFilter Is String.Empty Then
        Else
            If StrComp(FilterStr, " ", CompareMethod.Text) = 0 Then
                FilterStr = strFilter
            Else
                FilterStr += "and " & strFilter
            End If
        End If
        Session("FilterStr") = FilterStr
        Return FilterStr
    End Function



Thanks,

Sreekanth

0
 

Author Comment

by:Sreekanth_Nagabandi
ID: 18021447
Hi,

  I appreciate your help. I have resolved the problem .

Thanks,

Sreekanth
0
 
LVL 143

Accepted Solution

by:
Guy Hengel [angelIII / a3] earned 2000 total points
ID: 18021732
>and unitid in (1,2,3,4,5,6,7,8)
I guess you resolved it by just removing the AND keyword...

anyhow, please post your answer here, and I will PAQ the question with points refunded.
0

Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Introduction As chip makers focus on adding processor cores over increasing clock speed, developers need to utilize the features of modern CPUs.  One of the ways we can do this is by implementing parallel algorithms in our software.   One recent…
Introduction When many people think of the WebBrowser (http://msdn.microsoft.com/en-us/library/2te2y1x6%28v=VS.85%29.aspx) control, they immediately think of a control which allows the viewing and navigation of web pages. While this is true, it's a…
Video by: ITPro.TV
In this episode Don builds upon the troubleshooting techniques by demonstrating how to properly monitor a vSphere deployment to detect problems before they occur. He begins the show using tools found within the vSphere suite as ends the show demonst…
How to fix incompatible JVM issue while installing Eclipse While installing Eclipse in windows, got one error like above and unable to proceed with the installation. This video describes how to successfully install Eclipse. How to solve incompa…

719 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