?
Solved

if statement c#

Posted on 2013-12-26
8
Medium Priority
?
265 Views
Last Modified: 2014-01-28
I have a reader but i am converting to c# from vb. what is the equivalent of.

 while (myReader.Read())
                        {
                            if (myReader(1) < 10)  << error here
                            {
                                Other = myReader.GetInt32(1);
                            }
0
Comment
Question by:Seven price
[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
  • 4
  • 3
8 Comments
 
LVL 3

Expert Comment

by:13Shadow
ID: 39740602
The code you posted is C#. Are you asking for the vb equivalent?
0
 
LVL 9

Author Comment

by:Seven price
ID: 39740634
Yes
 Dim cIdx As Integer = -1
        Dim Other As Integer
        Dim NotProvided As Integer

  Do While sqlDR.Read
            If sqlDR("ttt") < 10 Then
                Other += sqlDR("ttt") 
            ElseIf sqlDR("ttt")  = "" Then
                NotProvided += sqlDR("ttt") 
            Else
                cIdx += 1
                ReDim Preserve yValues(cIdx)
                ReDim Preserve xValues(cIdx)
                xValues(cIdx) = sqlDR("ttt") 
                yValues(cIdx) = sqlDR("AAA") 
            End If
        Loop

        If Other > 0 Then
            cIdx += 1
            ReDim Preserve yValues(cIdx)
            ReDim Preserve xValues(cIdx)
            xValues(cIdx) = "Other"
            yValues(cIdx) = Other
        End If

        If NotProvided >= 0 Or NotProvided = "0" Then
            cIdx += 1
            ReDim Preserve yValues(cIdx)
            ReDim Preserve xValues(cIdx)
            xValues(cIdx) = "Not Provided"
            yValues(cIdx) = NotProvided
        End If

Open in new window

0
 
LVL 9

Author Comment

by:Seven price
ID: 39740636
Even the c# code comes out as error when I use the less than sign with an integer.
0
Veeam Disaster Recovery in Microsoft Azure

Veeam PN for Microsoft Azure is a FREE solution designed to simplify and automate the setup of a DR site in Microsoft Azure using lightweight software-defined networking. It reduces the complexity of VPN deployments and is designed for businesses of ALL sizes.

 
LVL 3

Assisted Solution

by:13Shadow
13Shadow earned 2000 total points
ID: 39740656
What are you trying to do in this statement?  If sqlDR("ttt") < 10 Then
0
 
LVL 3

Accepted Solution

by:
13Shadow earned 2000 total points
ID: 39740715
If you are trying to compare the value to 10 you need to convert it to integer first since the reader returns string values:
If CType(sqlDR("ttt"), Integer) < 10 Then
0
 
LVL 9

Author Comment

by:Seven price
ID: 39740741
  List<double> yValues = new List<double>();
                    List<string> xValues = new List<string>();
  while (myReader.Read())
                        {{
 xValues.Add(Convert.ToString(myReader[0]));
                                yValues.Add(Convert.ToDouble(myReader[1]));
}
                   

Open in new window


I want to add a if statement in the code above. if myreader(0) < 10 then do something else.
0
 
LVL 9

Author Closing Comment

by:Seven price
ID: 39740746
got it thanks
0
 

Expert Comment

by:rbgaikwad
ID: 39814474
While myReader.Read()
      If myReader(1) < 10 Then
            Other = myReader.GetInt32(1)
      End If
End While
0

Featured Post

Efficient way to get backups off site to Azure

This user guide provides instructions on how to deploy and configure both a StoneFly Scale Out NAS Enterprise Cloud Drive virtual machine and Veeam Cloud Connect in the Microsoft Azure Cloud.

Question has a verified solution.

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

In my previous two articles we discussed Binary Serialization (http://www.experts-exchange.com/A_4362.html) and XML Serialization (http://www.experts-exchange.com/A_4425.html). In this article we will try to know more about SOAP (Simple Object Acces…
Many of us here at EE write code. Many of us write exceptional code; just as many of us write exception-prone code. As we all should know, exceptions are a mechanism for handling errors which are typically out of our control. From database errors, t…
This is Part 3 in a 3-part series on Experts Exchange to discuss error handling in VBA code written for Excel. Part 1 of this series discussed basic error handling code using VBA. http://www.experts-exchange.com/videos/1478/Excel-Error-Handlin…
In this video you will find out how to export Office 365 mailboxes using the built in eDiscovery tool. Bear in mind that although this method might be useful in some cases, using PST files as Office 365 backup is troublesome in a long run (more on t…

777 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