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. [Message Deleted]

[Message Deleted]

Scheduled Pinned Locked Moved C / C++ / MFC
12 Posts 3 Posters 1 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.
  • Y Offline
    Y Offline
    yogendra kaushik
    wrote on last edited by
    #1

    [Message Deleted]

    E V 2 Replies Last reply
    0
    • Y yogendra kaushik

      [Message Deleted]

      E Offline
      E Offline
      Eytukan
      wrote on last edited by
      #2

      Quite blunt, but why do you say if (!res) ? shouldn't it be if(res) ? (It depends on how you assume.But generally if a function executes successfully , it returns a positive value or a true, If the function is done by you, you follow it too)

      yogendra kaushik wrote:

      if (i != 1)

      And here, I suggest you check (i>0) (in general) and you miss the else part. make an else part of the second if then display AfxMessageBox "Not Found!"


      --[:jig:]-- [My Current Status]

      Y 1 Reply Last reply
      0
      • E Eytukan

        Quite blunt, but why do you say if (!res) ? shouldn't it be if(res) ? (It depends on how you assume.But generally if a function executes successfully , it returns a positive value or a true, If the function is done by you, you follow it too)

        yogendra kaushik wrote:

        if (i != 1)

        And here, I suggest you check (i>0) (in general) and you miss the else part. make an else part of the second if then display AfxMessageBox "Not Found!"


        --[:jig:]-- [My Current Status]

        Y Offline
        Y Offline
        yogendra kaushik
        wrote on last edited by
        #3

        yar this will not work as if it delete sucessfully it will not display message and if i enter wrong id it willnot display message Please mail me

        1 Reply Last reply
        0
        • Y yogendra kaushik

          [Message Deleted]

          V Offline
          V Offline
          Viorel
          wrote on last edited by
          #4

          Maybe mysql_num_rows can be used only with SQL statements which return result set? Check the documentation. If no other solutions, I think you can first execute a SELECT statement in order to see if there is a row, then use mysql_num_rows to check the result, and after this use DELETE.

          Y 1 Reply Last reply
          0
          • V Viorel

            Maybe mysql_num_rows can be used only with SQL statements which return result set? Check the documentation. If no other solutions, I think you can first execute a SELECT statement in order to see if there is a row, then use mysql_num_rows to check the result, and after this use DELETE.

            Y Offline
            Y Offline
            yogendra kaushik
            wrote on last edited by
            #5

            [Message Deleted]

            V E 2 Replies Last reply
            0
            • Y yogendra kaushik

              [Message Deleted]

              V Offline
              V Offline
              Viorel
              wrote on last edited by
              #6

              Maybe you forgot to execute the SELECT statement with mysql_query or mysql_real_query?

              Y 1 Reply Last reply
              0
              • Y yogendra kaushik

                [Message Deleted]

                E Offline
                E Offline
                Eytukan
                wrote on last edited by
                #7

                First try hard-coding your SQL statement. i.e select * from empinfo where empid = 111 and see if it works. Mostly the bug sits in the way we assemble the string. And if the hard-coding works fine, try to make your sql string and before excuting it, Display it in a message box or in a CEdit so that you could verify that you are passing a well formed query string. Or you can also set check points to see the string.


                --[:jig:]-- [My Current Status]

                1 Reply Last reply
                0
                • V Viorel

                  Maybe you forgot to execute the SELECT statement with mysql_query or mysql_real_query?

                  Y Offline
                  Y Offline
                  yogendra kaushik
                  wrote on last edited by
                  #8

                  sir u r the man who can solve any problem its amazing thanks a lot sir i want to fetch date from mysql table with other values that is when i press fetch button in mfc dialogbox it will display values from mysql table into dialog box's edit boxes . all values are fetched but date does not as the mysql date format is yyyy-mm-dd and the datetime picker in mfc has the format dd-mm-yyyy plz tel me how to fetch it Please mail me

                  V 1 Reply Last reply
                  0
                  • Y yogendra kaushik

                    sir u r the man who can solve any problem its amazing thanks a lot sir i want to fetch date from mysql table with other values that is when i press fetch button in mfc dialogbox it will display values from mysql table into dialog box's edit boxes . all values are fetched but date does not as the mysql date format is yyyy-mm-dd and the datetime picker in mfc has the format dd-mm-yyyy plz tel me how to fetch it Please mail me

                    V Offline
                    V Offline
                    Viorel
                    wrote on last edited by
                    #9

                    Maybe like this:

                    const char * const s = "2006-06-12" ; // the date in yyyy-mm-dd format
                    int year, month, day;
                    sscanf(s, "%i-%i-%i", &year, &month, &day);
                    CTime const t(year, month, day, 0, 0, 0);
                    m_cMyDateTimePicker.SetTime(&t);
                    
                    Y 1 Reply Last reply
                    0
                    • V Viorel

                      Maybe like this:

                      const char * const s = "2006-06-12" ; // the date in yyyy-mm-dd format
                      int year, month, day;
                      sscanf(s, "%i-%i-%i", &year, &month, &day);
                      CTime const t(year, month, day, 0, 0, 0);
                      m_cMyDateTimePicker.SetTime(&t);
                      
                      Y Offline
                      Y Offline
                      yogendra kaushik
                      wrote on last edited by
                      #10

                      but sir wat iwill enter in place of date 2006-06-12 otherwise it will give only this date. i dont know but value stored in mysql table const char * const s = "2006-06-12" ; Please mail me

                      V 1 Reply Last reply
                      0
                      • Y yogendra kaushik

                        but sir wat iwill enter in place of date 2006-06-12 otherwise it will give only this date. i dont know but value stored in mysql table const char * const s = "2006-06-12" ; Please mail me

                        V Offline
                        V Offline
                        Viorel
                        wrote on last edited by
                        #11

                        It was just a sample. In your application you probably get date from database with a SELECT statement, let us say "SELECT id, name, date, count FROM myTable" (this is just a sample). Then you use mysql_query and finally something like res = mysql_store_result(myDB). Now you can access the date value, which is the third field of the statement:

                        char * s = row[2];
                        

                        Put a breakpoint here and see if the date value is valid. Then use the previous sample to display it.

                        Y 1 Reply Last reply
                        0
                        • V Viorel

                          It was just a sample. In your application you probably get date from database with a SELECT statement, let us say "SELECT id, name, date, count FROM myTable" (this is just a sample). Then you use mysql_query and finally something like res = mysql_store_result(myDB). Now you can access the date value, which is the third field of the statement:

                          char * s = row[2];
                          

                          Put a breakpoint here and see if the date value is valid. Then use the previous sample to display it.

                          Y Offline
                          Y Offline
                          yogendra kaushik
                          wrote on last edited by
                          #12

                          thanks a lot sir can i hav ur personel mail id if possible and u dont mind Please mail me

                          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