-
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;
}
-
I dont know about anything else but remove the '&' from the 2nd and 3rd scanf() calls.
Code:
scanf("%s",fname);
scanf("%s",lname);
-
No DB2? I'm feeling slighted.
-
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