Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C#
  4. EvaluateException at Select-Funktion

EvaluateException at Select-Funktion

Scheduled Pinned Locked Moved C#
helpcsharpvisual-studio
10 Posts 5 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • D Offline
    D Offline
    der flori
    wrote on last edited by
    #1

    Hi, I´d like to select DataRows with an Id and a Date, but I always get the following Error-Message: Cannot perform '=' operation on System.DateTime and System.String. Here my Code:

    string BehID = data1.Behandlungen.Rows.Count.ToString();
    string datum = microsim1["picdate"].ToString();
    DataRow[] VerlaufDatum = data1.Verlauf.Select("BehandlungsID=" + BehID + " AND Datum= '" + datum + "'");

    It worked perfectly witch Visual Studio 2003, but with Visual Studio 2008 I always get this Exception :( thanks for your help.

    M C L 4 Replies Last reply
    0
    • D der flori

      Hi, I´d like to select DataRows with an Id and a Date, but I always get the following Error-Message: Cannot perform '=' operation on System.DateTime and System.String. Here my Code:

      string BehID = data1.Behandlungen.Rows.Count.ToString();
      string datum = microsim1["picdate"].ToString();
      DataRow[] VerlaufDatum = data1.Verlauf.Select("BehandlungsID=" + BehID + " AND Datum= '" + datum + "'");

      It worked perfectly witch Visual Studio 2003, but with Visual Studio 2008 I always get this Exception :( thanks for your help.

      M Offline
      M Offline
      musefan
      wrote on last edited by
      #2

      im suprised it worked in any version youor trying to compare a string to a dateTime which clearly is not the same type As the BehID is unique why use the datum value at all?

      If only MySelf.Visible was more than just a getter... A person can produce over 5 times there own body weight in excrement each year... please re-read your questions before posting

      1 Reply Last reply
      0
      • D der flori

        Hi, I´d like to select DataRows with an Id and a Date, but I always get the following Error-Message: Cannot perform '=' operation on System.DateTime and System.String. Here my Code:

        string BehID = data1.Behandlungen.Rows.Count.ToString();
        string datum = microsim1["picdate"].ToString();
        DataRow[] VerlaufDatum = data1.Verlauf.Select("BehandlungsID=" + BehID + " AND Datum= '" + datum + "'");

        It worked perfectly witch Visual Studio 2003, but with Visual Studio 2008 I always get this Exception :( thanks for your help.

        C Offline
        C Offline
        Calin Tatar
        wrote on last edited by
        #3

        Hi, Try to create a DateTime object from

        datum

        , to see if you have a valid data format in that string. Calin

        D 1 Reply Last reply
        0
        • D der flori

          Hi, I´d like to select DataRows with an Id and a Date, but I always get the following Error-Message: Cannot perform '=' operation on System.DateTime and System.String. Here my Code:

          string BehID = data1.Behandlungen.Rows.Count.ToString();
          string datum = microsim1["picdate"].ToString();
          DataRow[] VerlaufDatum = data1.Verlauf.Select("BehandlungsID=" + BehID + " AND Datum= '" + datum + "'");

          It worked perfectly witch Visual Studio 2003, but with Visual Studio 2008 I always get this Exception :( thanks for your help.

          L Offline
          L Offline
          Lodeclaw
          wrote on last edited by
          #4

          You need to convert one or both sides of your statement so that they are both the same data type. A string type and a datetime type are incompatible, so find a way to collect the datetime information contained in your string explicitly and use DateTime.Parse to make it compatible.

          1 Reply Last reply
          0
          • D der flori

            Hi, I´d like to select DataRows with an Id and a Date, but I always get the following Error-Message: Cannot perform '=' operation on System.DateTime and System.String. Here my Code:

            string BehID = data1.Behandlungen.Rows.Count.ToString();
            string datum = microsim1["picdate"].ToString();
            DataRow[] VerlaufDatum = data1.Verlauf.Select("BehandlungsID=" + BehID + " AND Datum= '" + datum + "'");

            It worked perfectly witch Visual Studio 2003, but with Visual Studio 2008 I always get this Exception :( thanks for your help.

            C Offline
            C Offline
            Calin Tatar
            wrote on last edited by
            #5

            Also, you should try to format your date as following: "#" + dt.Month + "/" + dt.Day + "/" + dt.Year + "#" Calin

            D E 2 Replies Last reply
            0
            • C Calin Tatar

              Hi, Try to create a DateTime object from

              datum

              , to see if you have a valid data format in that string. Calin

              D Offline
              D Offline
              der flori
              wrote on last edited by
              #6

              I already tried to create a DateTime Object from

              datum

              and the Cast worked perfectly, but there occurs the same Exception when I edit the Code as follows:

              DataRow[] VerlaufDatum = data1.Verlauf.Select("BehandlungsID=" + BehID + " AND Datum= '" + Convert.ToDateTime(datum) + "'");

              I think it has something to do with the '=' Operator, but I don´t know what´s wrong with it :(

              C 1 Reply Last reply
              0
              • D der flori

                I already tried to create a DateTime Object from

                datum

                and the Cast worked perfectly, but there occurs the same Exception when I edit the Code as follows:

                DataRow[] VerlaufDatum = data1.Verlauf.Select("BehandlungsID=" + BehID + " AND Datum= '" + Convert.ToDateTime(datum) + "'");

                I think it has something to do with the '=' Operator, but I don´t know what´s wrong with it :(

                C Offline
                C Offline
                Calin Tatar
                wrote on last edited by
                #7

                Try by formatting the date and pass this string: "#" + dt.Month + "/" + dt.Day + "/" + dt.Year + "#" Calin

                1 Reply Last reply
                0
                • C Calin Tatar

                  Also, you should try to format your date as following: "#" + dt.Month + "/" + dt.Day + "/" + dt.Year + "#" Calin

                  D Offline
                  D Offline
                  der flori
                  wrote on last edited by
                  #8

                  hey, thanks a lot :))) that works fine and solves the problem perfectly!

                  C 1 Reply Last reply
                  0
                  • D der flori

                    hey, thanks a lot :))) that works fine and solves the problem perfectly!

                    C Offline
                    C Offline
                    Calin Tatar
                    wrote on last edited by
                    #9

                    I'm glad, no problem. Calin

                    1 Reply Last reply
                    0
                    • C Calin Tatar

                      Also, you should try to format your date as following: "#" + dt.Month + "/" + dt.Day + "/" + dt.Year + "#" Calin

                      E Offline
                      E Offline
                      Ennis Ray Lynch Jr
                      wrote on last edited by
                      #10

                      Ah, I love being reminded of Jet. Now we know where they DataSet team got there start.

                      Need custom software developed? I do C# development and consulting all over the United States.
                      If you don't ask questions the answers won't stand in your way.
                      Doing a job is like selecting a mule, you can't choose just the front half xor the back half so when you ask me to do a job don't expect me to do it half-assed.

                      1 Reply Last reply
                      0
                      Reply
                      • Reply as topic
                      Log in to reply
                      • Oldest to Newest
                      • Newest to Oldest
                      • Most Votes


                      • Login

                      • Don't have an account? Register

                      • Login or register to search.
                      • First post
                        Last post
                      0
                      • Categories
                      • Recent
                      • Tags
                      • Popular
                      • World
                      • Users
                      • Groups