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 / C++ / MFC
  4. Error in Query execution

Error in Query execution

Scheduled Pinned Locked Moved C / C++ / MFC
databasehelpquestioncareer
13 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.
  • V vc _fragrance

    Hi, Can u plz help me to rectify the error. 1)If i write the code as shown below I am getting the correct results SQLCHAR SQL[] = "SELECT EmployeeID,Salary FROM EMPLOYEE WHERE EmpName='tejaswini'"; 2)If I write the code as shown below I am getting an error saying that error in execution. What is the wrong with my code? CStirng Str="tejaswini"; SQLCHAR SQL[] = "SELECT EmployeeID,Salary FROM EMPLOYEE WHERE EmpName=Str"; Plz help me. Thanks in advance;

    P Offline
    P Offline
    pelaez
    wrote on last edited by
    #4

    Si Str va en el texto entrecomillado el ordenador lo interpreta como texto y no como tu variable. Desconozco como funciona un SQLCHAR, si el texto fuera un CString deberías ponerlo así... "SELECT EmployeeID, Salary FROM EMPLOYEE WHERE EmpName='" + Str + "´"; En este caso si cambiará Str por el valor de tu variable, además recuerda que en la sentencia Where EmpName= algo, ese algo tiene que ir entre comillas simples. Espero haberte ayudado.

    T V 2 Replies Last reply
    0
    • P pelaez

      Si Str va en el texto entrecomillado el ordenador lo interpreta como texto y no como tu variable. Desconozco como funciona un SQLCHAR, si el texto fuera un CString deberías ponerlo así... "SELECT EmployeeID, Salary FROM EMPLOYEE WHERE EmpName='" + Str + "´"; En este caso si cambiará Str por el valor de tu variable, además recuerda que en la sentencia Where EmpName= algo, ese algo tiene que ir entre comillas simples. Espero haberte ayudado.

      T Offline
      T Offline
      toxcct
      wrote on last edited by
      #5

      Hablamos inglés aquì señor... :(


      TOXCCT >>> GEII power

      [VisualCalc 3.0  updated ][Flags Beginner's Guide  new! ]

      N 1 Reply Last reply
      0
      • T toxcct

        Hablamos inglés aquì señor... :(


        TOXCCT >>> GEII power

        [VisualCalc 3.0  updated ][Flags Beginner's Guide  new! ]

        N Offline
        N Offline
        Naveen
        wrote on last edited by
        #6

        :confused:

        nave

        T 1 Reply Last reply
        0
        • N Naveen

          :confused:

          nave

          T Offline
          T Offline
          toxcct
          wrote on last edited by
          #7

          i told him that we were speaking english here !


          TOXCCT >>> GEII power

          [VisualCalc 3.0  updated ][Flags Beginner's Guide  new! ]

          N N 2 Replies Last reply
          0
          • T toxcct

            i told him that we were speaking english here !


            TOXCCT >>> GEII power

            [VisualCalc 3.0  updated ][Flags Beginner's Guide  new! ]

            N Offline
            N Offline
            Nibu babu thomas
            wrote on last edited by
            #8

            toxcct wrote:

            i told him that we were speaking english here !

            Quite obviously.:)


            Nibu thomas A Developer Programming tips[^]  My site[^]

            1 Reply Last reply
            0
            • T toxcct

              i told him that we were speaking english here !


              TOXCCT >>> GEII power

              [VisualCalc 3.0  updated ][Flags Beginner's Guide  new! ]

              N Offline
              N Offline
              Naveen
              wrote on last edited by
              #9

              but which language was that?

              nave

              T 1 Reply Last reply
              0
              • P pelaez

                Si Str va en el texto entrecomillado el ordenador lo interpreta como texto y no como tu variable. Desconozco como funciona un SQLCHAR, si el texto fuera un CString deberías ponerlo así... "SELECT EmployeeID, Salary FROM EMPLOYEE WHERE EmpName='" + Str + "´"; En este caso si cambiará Str por el valor de tu variable, además recuerda que en la sentencia Where EmpName= algo, ese algo tiene que ir entre comillas simples. Espero haberte ayudado.

                V Offline
                V Offline
                vc _fragrance
                wrote on last edited by
                #10

                Thank you. I tried it and am getting error Cannot convert from class CString to unsigned char[]; I tried to convert 'Str' to char variable as shown below; CString csStr(Str); char* pbuff = csStr.GetBuffer(csStr.GetLength()); SQLCHAR SQL[] = "SELECT EmpID,Salary FROM Employee WHERE EmpName='"+pbuff +"'"; Now i am getting the error as "Can not add two pointers" Plz help me to solve the problem. Thanks in advance.

                T 1 Reply Last reply
                0
                • N Naveen

                  but which language was that?

                  nave

                  T Offline
                  T Offline
                  toxcct
                  wrote on last edited by
                  #11

                  spanish buddy :cool:


                  TOXCCT >>> GEII power

                  [VisualCalc 3.0  updated ][Flags Beginner's Guide  new! ]

                  N 1 Reply Last reply
                  0
                  • T toxcct

                    spanish buddy :cool:


                    TOXCCT >>> GEII power

                    [VisualCalc 3.0  updated ][Flags Beginner's Guide  new! ]

                    N Offline
                    N Offline
                    Naveen
                    wrote on last edited by
                    #12

                    gracias:)

                    nave

                    1 Reply Last reply
                    0
                    • V vc _fragrance

                      Thank you. I tried it and am getting error Cannot convert from class CString to unsigned char[]; I tried to convert 'Str' to char variable as shown below; CString csStr(Str); char* pbuff = csStr.GetBuffer(csStr.GetLength()); SQLCHAR SQL[] = "SELECT EmpID,Salary FROM Employee WHERE EmpName='"+pbuff +"'"; Now i am getting the error as "Can not add two pointers" Plz help me to solve the problem. Thanks in advance.

                      T Offline
                      T Offline
                      toxcct
                      wrote on last edited by
                      #13

                      tejaswini.g wrote:

                      SQLCHAR SQL[] = "SELECT EmpID,Salary FROM Employee WHERE EmpName='"+pbuff +"'";

                      change into this : SQLCHAR SQL[] = CString("SELECT EmpID,Salary FROM Employee WHERE EmpName='") + csStr + "'";


                      TOXCCT >>> GEII power

                      [VisualCalc 3.0  updated ][Flags Beginner's Guide  new! ]

                      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