Thread: Database Conectivity

  1. #1
    Registered User
    Join Date
    Dec 2009
    Location
    Mumbai
    Posts
    3

    Database Conectivity

    I am writing a C program requiring database connectivity, can someone help/provide resources with the same. I am trying to connect with SOL Server 2000.
    Also provide resources for Oracle 11g, MySQL and SQL Server 2005/2008.
    Code:
    #include<stdio.h>
    #include<conio.h>
    #include<stdlib.h>
    EXEC SQL INCLUDE sqlca;
    int main(void)
    {
    	clrscr();
            int number;
            char fname[80];
            char lname[80];
    	printf("Enter a number : ");
    	scanf("%d",&number);
    	printf("Enter your first name : ");
    	scanf("%s",&fname);
    	printf("Enter your last name  : ");
    	scanf("%s",&lname);
    	EXEC SQL INSERT INTO Table1 values(:number,:fname,:lname,);
    	getch();
    	return 0;
    }
    Last edited by Dark Sorrow; 12-25-2009 at 01:58 AM.

  2. #2
    DESTINY BEN10's Avatar
    Join Date
    Jul 2008
    Location
    in front of my computer
    Posts
    804
    I dont know about anything else but remove the '&' from the 2nd and 3rd scanf() calls.
    Code:
    scanf("%s",fname);
    scanf("%s",lname);
    HOPE YOU UNDERSTAND.......

    By associating with wise people you will become wise yourself
    It's fine to celebrate success but it is more important to heed the lessons of failure
    We've got to put a lot of money into changing behavior


    PC specifications- 512MB RAM, Windows XP sp3, 2.79 GHz pentium D.
    IDE- Microsoft Visual Studio 2008 Express Edition

  3. #3
    Jack of many languages Dino's Avatar
    Join Date
    Nov 2007
    Location
    Chappell Hill, Texas
    Posts
    2,332
    No DB2? I'm feeling slighted.
    Mainframe assembler programmer by trade. C coder when I can.

  4. #4
    Registered User jeffcobb's Avatar
    Join Date
    Dec 2009
    Location
    Henderson, NV
    Posts
    875
    Based on your selections, it seems more like a question on how to configure your project to speak to those different database systems rather than a coding question...in this case the SQL (the common language used to access these different systems) would be the same and since the lions-share of your database servers are Windows-based so it looks more like how to link four different database systems to your application....the only one I have C-level experience with is MySQL which generally involves connecting to the database (which from your code I assume you have already created with the proper system tools) and using the returned DB "handle" to issue SQL statements which it looks like you are creating already in your code...check out this link:
    MySQL C API under Linux
    C/C++ Environment: GNU CC/Emacs
    Make system: CMake
    Debuggers: Valgrind/GDB

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. literature database: help with planning
    By officedog in forum C++ Programming
    Replies: 1
    Last Post: 01-23-2009, 12:34 PM
  2. Creating a database
    By Shamino in forum Game Programming
    Replies: 19
    Last Post: 06-10-2007, 01:09 PM
  3. Replies: 10
    Last Post: 05-18-2006, 11:23 PM
  4. Developing database management software
    By jdm in forum C++ Programming
    Replies: 4
    Last Post: 06-15-2004, 04:06 PM
  5. Making a Simple Database System
    By Speedy5 in forum C++ Programming
    Replies: 1
    Last Post: 03-14-2003, 10:17 PM