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. Error..

Error..

Scheduled Pinned Locked Moved C#
help
13 Posts 7 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.
  • M mjawadkhatri

    please read this and tell me my mistake. cn.Open(); cmd.CommandText = "Select ATT_DATE,DEP_ID,to_char(timein,'HH:MI'),to_char(timeout,'HH:MI'),EMP_NAME from attandance where emp_id = '" + id.Text + "' and shift = '" + shift.SelectedItem + "'"; odr = cmd.ExecuteReader(); while (odr.Read()) { ename.Text = odr["emp_name"].ToString(); dept.Text = odr["dep_id"].ToString(); timein.Text = odr["timein"].ToString(); timeout.Text = odr["timeout"].ToString(); Dte.Text = odr["att_date"].ToString(); }

    R Offline
    R Offline
    riced
    wrote on last edited by
    #3

    mjawadkhatri wrote:

    tell me my mistake.

    Not telling us what the error message says and which line it occurs on? :)

    Regards David R --------------------------------------------------------------- "Every program eventually becomes rococo, and then rubble." - Alan Perlis

    M 1 Reply Last reply
    0
    • C Christian Graus

      That depends. what is going wrong ? Is there an error message ?

      Christian Graus Driven to the arms of OSX by Vista. Read my blog to find out how I've worked around bugs in Microsoft tools and frameworks.

      M Offline
      M Offline
      mjawadkhatri
      wrote on last edited by
      #4

      Error Message is INDEX OUT OF RANGE EXCEPTION WAS UNHANDLED

      M 1 Reply Last reply
      0
      • R riced

        mjawadkhatri wrote:

        tell me my mistake.

        Not telling us what the error message says and which line it occurs on? :)

        Regards David R --------------------------------------------------------------- "Every program eventually becomes rococo, and then rubble." - Alan Perlis

        M Offline
        M Offline
        mjawadkhatri
        wrote on last edited by
        #5

        Error Message is INDEX OUT OF RANGE EXCEPTION WAS UNHANDLED line of Error is timein.Text = odr["timein"].ToString();

        C 1 Reply Last reply
        0
        • M mjawadkhatri

          Error Message is INDEX OUT OF RANGE EXCEPTION WAS UNHANDLED

          M Offline
          M Offline
          Mbah Dhaim
          wrote on last edited by
          #6

          that because you dont specify return field name for time in try change your query in "to_char('timein',...) as timein" hope it helps

          dhaim ing ngarso sung tulodho, ing madyo mangun karso, tut wuri handayani. "Ki Hajar Dewantoro" in the front line gave a lead, in the middle line build goodwill, in the behind give power support

          M 1 Reply Last reply
          0
          • M Mbah Dhaim

            that because you dont specify return field name for time in try change your query in "to_char('timein',...) as timein" hope it helps

            dhaim ing ngarso sung tulodho, ing madyo mangun karso, tut wuri handayani. "Ki Hajar Dewantoro" in the front line gave a lead, in the middle line build goodwill, in the behind give power support

            M Offline
            M Offline
            mjawadkhatri
            wrote on last edited by
            #7

            I change my query like; "to_char('timein','HH:MI')as timein" now Error Message Change ERROR [22018] [Microsoft][ODBC driver for Oracle][Oracle]ORA-01722: invalid number

            M 1 Reply Last reply
            0
            • M mjawadkhatri

              Error Message is INDEX OUT OF RANGE EXCEPTION WAS UNHANDLED line of Error is timein.Text = odr["timein"].ToString();

              C Offline
              C Offline
              Christian Graus
              wrote on last edited by
              #8

              So, there is no column called 'timein'. I suspect you need to read a few basic books before doing any more work, the error message is pretty self documenting, and googling it would have got you a ton of info

              Christian Graus Driven to the arms of OSX by Vista. Read my blog to find out how I've worked around bugs in Microsoft tools and frameworks.

              1 Reply Last reply
              0
              • M mjawadkhatri

                I change my query like; "to_char('timein','HH:MI')as timein" now Error Message Change ERROR [22018] [Microsoft][ODBC driver for Oracle][Oracle]ORA-01722: invalid number

                M Offline
                M Offline
                Mbah Dhaim
                wrote on last edited by
                #9

                then try to follow this link ORA-01722: invalid number[^] hope it helps

                dhaim ing ngarso sung tulodho, ing madyo mangun karso, tut wuri handayani. "Ki Hajar Dewantoro" in the front line gave a lead, in the middle line build goodwill, in the behind give power support

                1 Reply Last reply
                0
                • M mjawadkhatri

                  please read this and tell me my mistake. cn.Open(); cmd.CommandText = "Select ATT_DATE,DEP_ID,to_char(timein,'HH:MI'),to_char(timeout,'HH:MI'),EMP_NAME from attandance where emp_id = '" + id.Text + "' and shift = '" + shift.SelectedItem + "'"; odr = cmd.ExecuteReader(); while (odr.Read()) { ename.Text = odr["emp_name"].ToString(); dept.Text = odr["dep_id"].ToString(); timein.Text = odr["timein"].ToString(); timeout.Text = odr["timeout"].ToString(); Dte.Text = odr["att_date"].ToString(); }

                  B Offline
                  B Offline
                  Blikkies
                  wrote on last edited by
                  #10

                  In your select statement set "to_char(timein,'HH:MI')" to "to_char(timein,'HH:MI') AS 'timein'" same with "to_char(timeout,'HH:MI')"

                  1 Reply Last reply
                  0
                  • M mjawadkhatri

                    please read this and tell me my mistake. cn.Open(); cmd.CommandText = "Select ATT_DATE,DEP_ID,to_char(timein,'HH:MI'),to_char(timeout,'HH:MI'),EMP_NAME from attandance where emp_id = '" + id.Text + "' and shift = '" + shift.SelectedItem + "'"; odr = cmd.ExecuteReader(); while (odr.Read()) { ename.Text = odr["emp_name"].ToString(); dept.Text = odr["dep_id"].ToString(); timein.Text = odr["timein"].ToString(); timeout.Text = odr["timeout"].ToString(); Dte.Text = odr["att_date"].ToString(); }

                    0 Offline
                    0 Offline
                    0x3c0
                    wrote on last edited by
                    #11

                    In addition to your missing columns, your code is vulnerable to SQL injection. You might want to look into stored procedures

                    Between the idea And the reality Between the motion And the act Falls the Shadow

                    P 1 Reply Last reply
                    0
                    • 0 0x3c0

                      In addition to your missing columns, your code is vulnerable to SQL injection. You might want to look into stored procedures

                      Between the idea And the reality Between the motion And the act Falls the Shadow

                      P Offline
                      P Offline
                      PIEBALDconsult
                      wrote on last edited by
                      #12

                      "You might want to look into stored procedures parameterized statements." (Regardless of whether or not the statement executes a stored procedure.)

                      0 1 Reply Last reply
                      0
                      • P PIEBALDconsult

                        "You might want to look into stored procedures parameterized statements." (Regardless of whether or not the statement executes a stored procedure.)

                        0 Offline
                        0 Offline
                        0x3c0
                        wrote on last edited by
                        #13

                        Whoops. I thought that stored procedures and parametrized statements were the same thing. Thanks for the tip - research time methinks :)

                        Between the idea And the reality Between the motion And the act Falls the Shadow

                        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