Need Help -- Database connectivity in C

Please support our C advertiser: Programming Forums - DaniWeb Sister Site
Closed Thread

Join Date: Oct 2006
Posts: 5
Reputation: Sivakumar_K is an unknown quantity at this point 
Solved Threads: 0
Sivakumar_K Sivakumar_K is offline Offline
Newbie Poster

Need Help -- Database connectivity in C

 
0
  #1
Oct 3rd, 2006
I saw the follwing coding in the forum..

But i dont know how to execute in the Turbo C compiler..

Or else we need to use seperate connectivity coding for Turbo C compiler????

Can i know the include files (Header files) for the coding given below..

-------------------------------------------------------------------------------------------------

HENV hEnv = NULL;
HDBC hDbc = NULL;
HSTMT hStmt = NULL;
UCHAR szDSN[SQL_MAX_DSN_LENGTH] = "himanshuDSN";
char szmodel[128];
char szmodel1[128];
char szmodel2[128];
SDWORD cbmodel;
SDWORD cbmodel1;
SDWORD cbmodel2;
RETCODE retcode;

//Query statement


UCHAR sql1[] = "Select subcode from registration where rollno=";
UCHAR sql2[] = "Select subcode from registration where rollno=";

int i,j,no = 1;
int rno;
char s[10];

SQLAllocEnv(&hEnv);
SQLAllocConnect(hEnv,&hDbc);

retcode = SQLConnect(hDbc,szDSN,SQL_NTS,'\0',SQL_NTS,'\0',SQL_NTS);


printf("Enter the roll no : ");
scanf("%d",&rno);
itoa(rno,s,10);
strcat(sql1,s);
if(retcode == SQL_SUCCESS|| retcode == SQL_SUCCESS_WITH_INFO)
{

retcode = SQLAllocStmt(hDbc,&hStmt);
retcode = SQLPrepare(hStmt,sql1,sizeof(sql1));
retcode = SQLExecute(hStmt);

printf("\nReading the records\n");

SQLBindCol(hStmt,no,SQL_C_CHAR,szmodel,sizeof(szmodel),&cbmodel);
//SQLBindCol(hStmt,no+1,SQL_C_CHAR,szmodel1,sizeof(szmodel1),&cbmodel1);
//SQLBindCol(hStmt,no+2,SQL_C_CHAR,szmodel2,sizeof(szmodel2),&cbmodel2);
retcode = SQLFetch(hStmt);

while(retcode == SQL_SUCCESS|| retcode == SQL_SUCCESS_WITH_INFO)
{
printf("\t%s \n",szmodel,szmodel1,szmodel2);
retcode = SQLFetch(hStmt);
}
SQLFreeStmt(hStmt,SQL_DROP);
SQLDisconnect(hDbc);
}else{
printf("Can not read the database\n");
}


SQLFreeConnect(hDbc);
SQLFreeEnv(hEnv



-------------------------------------------------------------------------------


I want to some understandable coding format with explanation!!..

Can anyone give me a suggestion?? i need it..



Thanks in advance..
Quick reply to this message  
Join Date: Oct 2006
Posts: 5
Reputation: Sivakumar_K is an unknown quantity at this point 
Solved Threads: 0
Sivakumar_K Sivakumar_K is offline Offline
Newbie Poster

Help -- Database connectivity in C using Dev-C++

 
0
  #2
Oct 3rd, 2006
Can anyone provide Sql server 2000 database connectivity coding using C language..


I came to know that 16-bit compiler is not suitable..

So i am using Dev-C++ compiler..

I need coding to compile in this compiler..

I need to use this connection in employee payslip application...

Please provide with some explanation..




Thanks in advance...
Quick reply to this message  
Join Date: Aug 2005
Posts: 15,413
Reputation: Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute 
Solved Threads: 1470
Team Colleague
Featured Poster
Ancient Dragon's Avatar
Ancient Dragon Ancient Dragon is offline Offline
Still Learning

Re: Help -- Database connectivity in C using Dev-C++

 
0
  #3
Oct 3rd, 2006
There are hundreds of free examples on the net, just google for "odbc c libraries". Here is just one of them

Or why not just compile the code you posted in your other thread?
Last edited by Ancient Dragon; Oct 3rd, 2006 at 8:16 am.
Quick reply to this message  
Join Date: Aug 2005
Posts: 15,413
Reputation: Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute 
Solved Threads: 1470
Team Colleague
Featured Poster
Ancient Dragon's Avatar
Ancient Dragon Ancient Dragon is offline Offline
Still Learning

Re: Help -- Database connectivity in C using Dev-C++

 
0
  #4
Oct 3rd, 2006
threads were merged.
Quick reply to this message  
Join Date: Aug 2007
Posts: 5
Reputation: anu john is an unknown quantity at this point 
Solved Threads: 0
anu john anu john is offline Offline
Newbie Poster

Re: Need Help -- Database connectivity in C

 
0
  #5
Aug 9th, 2007
Hi everyone..
i wanted to know if it is possible to connect my microcontroller to the sql server 2005 using c-language. i intend to use 8051 controller and Keil compiler for the same.Also can ne1 give me the code for the same........
plz reply.
Quick reply to this message  
Closed Thread

This thread is more than three months old.
Perhaps start a new thread instead?
Message:


Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC