Thread: Possible or Not?

  1. #1
    Registered User
    Join Date
    Aug 2006
    Posts
    30

    Possible or Not?

    It is possible, using C programming language, can interact with modern databases today such as MySQL, MSSQL, FireBird, etc? If possible, how can I do that? Is there a built functions for that...

    Note: I am talking about the older version of C or C++ using the console like Borland 3.0 C++ or purely C programming language.

    If it not possible, how can I make records then call that records using C? Hope you can give me more ideas about this matter. Thanks.

  2. #2
    ATH0 quzah's Avatar
    Join Date
    Oct 2001
    Posts
    14,826
    Why don't you just go to the MySQL website and look at their API? But why on earth are you using such an old compiler? Go get a new one.


    Quzah.
    Hope is the first step on the road to disappointment.

  3. #3
    and Nothing Else Matters
    Join Date
    Jul 2006
    Location
    Philippines
    Posts
    117
    My current compiler (Lcc-win32) has an SQLite.h file in it's "include" folder.. i guess it means it is therefore possible neo_phyte
    It is not who I am inside but what I do that defines me.

  4. #4
    Just kidding.... fnoyan's Avatar
    Join Date
    Jun 2003
    Location
    Still in the egg
    Posts
    275
    Quote Originally Posted by sangken
    My current compiler (Lcc-win32) has an SQLite.h file in it's "include" folder.. i guess it means it is therefore possible neo_phyte
    Having header files does not mean that you have required environment. You also need library files to write programs for any purpose.

    neo_phyte : "mysql c" search this in google. And see the first link

  5. #5
    Registered User
    Join Date
    Aug 2006
    Posts
    30
    I guess I have to study it further, I am confused about the coding:

    1. Do I need a connection string for this? Just as usual use by other modern programming language today?

    2. I know a little bit with PHP connected to MySQL, and I know about mysql_connect, mysql_query functions, etc... Do I need these functions in coding in C? Do I download header file on this functions? If it is downloadable, what is the link for that?

    3. It is possible to create a database in a text file? What I mean, all the records are based in text file and call it in C?

    4. Hope you can give me further illustrations or link where I can study about this matter.


    Many thanks who responses this concern... Thank you very much...
    Last edited by neo_phyte; 09-07-2006 at 03:55 AM.

  6. #6
    Registered User
    Join Date
    Aug 2006
    Posts
    30
    I found this code in the net, I understand with these codes, but what makes me confused is the #include <mysql.h>.. where i can get this header file? or can we download it?


    Code:
    #include <mysql.h>
    #include <stdio.h>
    
    main() {
       MYSQL *conn;
       MYSQL_RES *res;
       MYSQL_ROW row;
    
       char *server = "mysql-server.ucl.ac.uk";
       char *user = "ucabwww";
       char *password = "secret";
       char *database = "ucabwww";
       
       conn = mysql_init(NULL);
       
       /* Connect to database */
       if (!mysql_real_connect(conn, server,
             user, password, database, 0, NULL, 0)) {
          fprintf(stderr, "%s\n", mysql_error(conn));
          exit(0);
       }
    
       /* send SQL query */
       if (mysql_query(conn, "SELECT * FROM people WHERE age > 30")) {
          fprintf(stderr, "%s\n", mysql_error(conn));
          exit(0);
       }
    
       res = mysql_use_result(conn);
       
       /* output fields 1 and 2 of each row */
       while ((row = mysql_fetch_row(res)) != NULL)
          printf("%s %s\n", row[1], row[2]);
    
       /* Release memory used to store results and close connection */
       mysql_free_result(res);
       mysql_close(conn);
    }
    It seems the problem is getting nearer for the solution. Thanks.

  7. #7
    ATH0 quzah's Avatar
    Join Date
    Oct 2001
    Posts
    14,826
    Damnit man, we have already told you. Go to MySQL.com! <--- CLICK CLICK CLICK


    Quzah.
    Hope is the first step on the road to disappointment.

  8. #8
    Just kidding.... fnoyan's Avatar
    Join Date
    Jun 2003
    Location
    Still in the egg
    Posts
    275
    Why do you keep asking questions persistently whose answers are available in the URLs we gave! Just click the links that Quzah gave or do what I said in my last post.

    Edit : One last thing. If you are goning to install MySQL from a binary package, you also have to install devel package seperately. In the case of tarball installation, the header files and libraries are installed.

  9. #9
    Registered User
    Join Date
    Aug 2006
    Posts
    30
    I am very sorry sir.... Anyway thank you to both of you... One last question... is this possible in Borland C++ 3.0 or lower version in C... Dont answer me to get a new updated compiler!!!

  10. #10
    ATH0 quzah's Avatar
    Join Date
    Oct 2001
    Posts
    14,826
    Stop asking then. Your compiler is worthless. I doubt they're going to waste time porting their database back to the stone age. There are better free compilers out there, go get one.


    Quzah.
    Hope is the first step on the road to disappointment.

  11. #11
    Gawking at stupidity
    Join Date
    Jul 2004
    Location
    Oregon, USA
    Posts
    3,218
    Yeah, get a newer compiler or change your name. "neophyte" indeed.
    If you understand what you're doing, you're not learning anything.

  12. #12
    Registered User
    Join Date
    Aug 2006
    Posts
    30
    okay.. thanks... itsme86... change also your name, how about itsyours86

  13. #13
    and Nothing Else Matters
    Join Date
    Jul 2006
    Location
    Philippines
    Posts
    117
    hmmm, i prefer itshim86
    It is not who I am inside but what I do that defines me.

  14. #14
    Registered User
    Join Date
    Sep 2006
    Posts
    8,868
    Quote Originally Posted by neo_phyte
    It is possible, using C programming language, can interact with modern databases today such as MySQL, MSSQL, FireBird, etc? If possible, how can I do that? Is there a built functions for that...

    Note: I am talking about the older version of C or C++ using the console like Borland 3.0 C++ or purely C programming language.

    If it not possible, how can I make records then call that records using C? Hope you can give me more ideas about this matter. Thanks.
    You CAN do darn near anything in C, but the question is, "Is it worth all the extra work to do it?". OOP programming in C, for instance, is just a TON of work, for little results. Use an OOP language, instead.

    But I'm NOT going to bad-mouth older compilers - I have and use Turbo C/C++ ver. 1.01 (that is not a misprint or typo!) and I use it a lot for little console programs.

    Of course you can code up a database program in C with an older compiler. Each record is just a struct with a few extra fields for indexing purposes. etc. I wrote up a small one earlier this year, but naturally it doesn't have all the features of a full-featured database.

    I'm not familiar with MySql, but if there's a header/library to work with MySql, I'm sure it would help immensely, to use them.

    Adak

  15. #15
    Registered User
    Join Date
    Jun 2006
    Posts
    75
    Quote Originally Posted by neo_phyte
    okay.. thanks... itsme86... change also your name, how about itsyours86
    itsI86 will be better; it's grammatically correct.

Popular pages Recent additions subscribe to a feed