Thread: DataBase access

  1. #1
    In The Light
    Join Date
    Oct 2001
    Posts
    598

    DataBase access

    howdy,
    i am at the point in an app where i will be accessing a database (AISC steel section properties). will i need a seperate utilitie to open a database and access it by field name etc...
    or does C++ have a library function that will allow searching a database by row or column.
    i have no code to offer because i have no idea how this is even attempted.

    ~~~~~~~wannabe code~~~~~~~~~~
    int i_have _a_value()
    {
    look in the data base for 5 values
    1 = i_have _a_value
    2 = next_two_higher_values
    2 = next_two_lower_values

    retrieve the entire rows containing these values
    } // or something like this

    ~~~~~~wannabe code~~~~~~~~~~~~~~

    the data base will be several hundred rows and about 20 columns.

    where do i start?

    Thanks
    M.R.

  2. #2
    the hat of redundancy hat nvoigt's Avatar
    Join Date
    Aug 2001
    Location
    Hannover, Germany
    Posts
    3,130
    Ask your database vendor if he provides you with an interface to C/C++. It very likely he will. It's a set of functions that you can use to access the data stored in the database. I can't tell you more, as the actual implementation is database specific. For Oracle for example, it's the OCI, Oracle Call Interface. For other vendors, there might be other solutions.
    hth
    -nv

    She was so Blonde, she spent 20 minutes looking at the orange juice can because it said "Concentrate."

    When in doubt, read the FAQ.
    Then ask a smart question.

  3. #3
    Registered User
    Join Date
    Dec 2001
    Posts
    194
    Are you using a professional/commercal database? If so nvoigt already answered your point.
    Or do you want to create a simple database yourself?
    You could make a structure or class to hold all the data for each object.
    Then make an array or whatever you want with this class.
    Using FILE * 's you can read and write entier arrays at once
    Code:
    	FILE * myfile;
    	int array[500];
    	int array2[500];
    	int i;
    	for( i=0 ; i<500 ; i++)
    	{
    		array[i]=i;
    	}
    	myfile = fopen("database","wb");//write/binary
    	fwrite(array,sizeof(int),500,myfile); //this should write the whole array to the text file
    	fclose(myfile); //close the file.
                   //do stuff here
    	myfile = fopen("database","rb"); //open the file for reading
    	fread(array2,sizeof(int),500,myfile);  //read in our array we wrote earlier
    That will make an array, write it to a file.
    Then the file is closed.
    The file can then be opened, and read in with one line

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Error connecting from Dev C++ to MS Access Database
    By Sridar in forum C++ Programming
    Replies: 0
    Last Post: 04-15-2006, 06:09 PM
  2. accessing a database made in Access..
    By willc0de4food in forum Windows Programming
    Replies: 4
    Last Post: 10-10-2005, 07:40 PM
  3. How to add a database from access in c++
    By m_abdelghani in forum Windows Programming
    Replies: 7
    Last Post: 03-24-2005, 08:19 AM
  4. Access Database Editor
    By Grayson_Peddie in forum Tech Board
    Replies: 21
    Last Post: 01-06-2004, 07:20 AM
  5. DataBase Access
    By itld in forum Linux Programming
    Replies: 0
    Last Post: 12-29-2001, 11:40 AM