c++ mysql++ WinMain windows programming

This is a discussion on c++ mysql++ WinMain windows programming within the C++ Programming forums, part of the General Programming Boards category; here's a snippet of the code I'm having trouble with: Code: case IDC_GET: MYSQL *pConnection; MYSQL_RES *pResult; //pointer to the ...

  1. #1
    Registered User juschillin's Avatar
    Join Date
    Sep 2002
    Posts
    20

    c++ mysql++ WinMain windows programming

    here's a snippet of the code I'm having trouble with:
    Code:
    	case IDC_GET:
    					MYSQL *pConnection; 
    					MYSQL_RES *pResult;   //pointer to the result set structure
    					MYSQL_ROW Row;
    					pConnection = mysql_init(NULL);
    					SendDlgItemMessage(hwnd, IDC_LIST, LB_ADDSTRING, 0, (LPARAM)TEXT("Attempting to Connect to"));
    					SendDlgItemMessage(hwnd, IDC_LIST, LB_ADDSTRING, 0, (LPARAM)TEXT("Database......."));
    					mysql_real_connect(pConnection, "localhost","alakazam","tripletkingsburg","tripletadmin",0,NULL,0);
        				SendDlgItemMessage(hwnd, IDC_LIST, LB_ADDSTRING, 0, (LPARAM)TEXT("Connected!"));
    					mysql_query(pConnection,"SELECT * FROM products"); //query the database
    					pResult = mysql_store_result(pConnection); 
    					printf("\n\nThe Number Of products in the database: %d\n\n",mysql_num_rows(pResult));
    					SendDlgItemMessage(hwnd, IDC_LIST, LB_ADDSTRING, 0, (LPARAM)printf("%d",mysql_num_rows(pResult)));
    					mysql_free_result(pResult);
    				break;




    This line is my real problem:

    SendDlgItemMessage(hwnd, IDC_LIST, LB_ADDSTRING, 0, (LPARAM)printf("%d",mysql_num_rows(pResult)));


    how do I print my results out to the IDC_LIST??

    Anybody who has done this please help.


    and remember that this is for gui interface not a dos console. I know how to do it in a dos console.
    !Carpe Diem!
    "Sieze the Day"

  2. #2
    Registered User
    Join Date
    Dec 2001
    Posts
    70
    Make a text buffer, use wsprintf instead of printf and use it outside SendDlgItemMessage function, and then pass the address of this buffer. Isn't it easy?

  3. #3
    Registered User juschillin's Avatar
    Join Date
    Sep 2002
    Posts
    20
    I'm pretty new at this stuff, would it be possible to give me an example?


    !Carpe Diem!
    "Sieze the Day"

  4. #4
    Registered User
    Join Date
    Dec 2001
    Posts
    70
    TCHAR szBuffer[50];

    wsprintf (szBuffer, TEXT ("%d"), mysql_num_rows (pResult));

    SendDlgItemMessage (hwnd, IDC_LIST, LB_ADDSTRING, 0, (LPARAM) szBuffer);

    This would work perhaps.

  5. #5
    Registered User juschillin's Avatar
    Join Date
    Sep 2002
    Posts
    20
    I love you guys!!!

    Thanks alot
    !Carpe Diem!
    "Sieze the Day"

  6. #6
    pronounced 'fib' FillYourBrain's Avatar
    Join Date
    Aug 2002
    Posts
    2,297
    golem, is your name supposed to be the character in lord of the rings? I could be wrong but isn't it spelled "gollum" or something like that?
    "You are stupid! You are stupid! Oh, and don't forget, you are STUPID!" - Dexter

  7. #7
    Registered User
    Join Date
    Dec 2001
    Posts
    70
    No, it's an historical monster made from clay by a jew rabbi which name I haven't remembered. I haven't seen that film.

  8. #8
    pronounced 'fib' FillYourBrain's Avatar
    Join Date
    Aug 2002
    Posts
    2,297
    LOL!

    I don't know if that was a joke or not but it was funny as hell. Haven't seen lord of the rings? It's pretty good. Worth your time. I was kinda referring to the books though.
    "You are stupid! You are stupid! Oh, and don't forget, you are STUPID!" - Dexter

  9. #9
    Registered User
    Join Date
    Dec 2001
    Posts
    70
    Among many films I've seen lately was Matrix and I thought
    I understood it. But what this topic has to do with general C++ ?

  10. #10
    pronounced 'fib' FillYourBrain's Avatar
    Join Date
    Aug 2002
    Posts
    2,297
    the original post belongs in the windows forum, our discussion belongs in General Discussion forum. I don't care if you don't
    "You are stupid! You are stupid! Oh, and don't forget, you are STUPID!" - Dexter

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Just starting Windows Programming, School me!
    By Shamino in forum Windows Programming
    Replies: 17
    Last Post: 02-22-2008, 08:14 AM
  2. how to make a windows application
    By crvenkapa in forum C++ Programming
    Replies: 3
    Last Post: 03-26-2007, 10:59 AM
  3. Script errors - bool unrecognized and struct issues
    By ulillillia in forum Windows Programming
    Replies: 10
    Last Post: 12-18-2006, 04:44 AM
  4. Manipulating the Windows Clipboard
    By Johno in forum Windows Programming
    Replies: 2
    Last Post: 10-01-2002, 10:37 AM
  5. Problem with Borland 5.5 Compiling Windows Programs
    By Unregistered in forum C++ Programming
    Replies: 3
    Last Post: 08-28-2001, 10:04 AM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21