Refer to the explanation on Inserting Records in the Database. The concept and the logic remains the same hence no explanations are given for the search program.
search.htm
<html> <body bgcolor=white text=black> <pre><blockquote> <html> <title> itpro - Professional Information Sheet </title> <body bgcolor=white text=black> <center><h1> Professional Information Sheet</h1> <h3> Query Form </h3> </center> <hr> <form method=get action="http://202.54.27.226/cgi-shl/qury.exe"> <input type=submit value="View all Records"> </body> </form> </blockquote></pre> </body> </html>
qury.c
#include <windows.h>
#include <sql.h>
#include <sqlext.h>
#include <stdio.h>
void *henv,*hdbc,*hstmt;
int idno;
char titlestr[4];
char fnamestr[41];
char desigstr[41];
char companystr[41];
char addressstr[1000];
char telestr[16];
char faxstr[16];
char emailstr[41];
char flagstr[2];
char qualistr[150];
int prgmno;
int analno;
int prjmgmtno;
char workareastr[149];
char toolstr[70];
char osstr[76];
char expstr[41];
char abb[1000],bbb[100],ccc[100];
int ret_code,result;
int l,l1;
_stdcall WinMain(HINSTANCE i, HINSTANCE j, char *k, int l)
{
	puts("Content-type:text/html\r\n\r\n");
	puts("<html>");
	puts("<body bgcolor=white text=black>");
	strcpy(abb,"Select * from bd");
	ret_code=SQLAllocEnv(&henv);
	ret_code=SQLAllocConnect(henv,&hdbc);
    ret_code=SQLConnect(hdbc,"sonal",-3,"aaa",-3,"aaa",-3);
	
    ret_code=SQLAllocStmt(hdbc,&hstmt);
	ret_code=SQLExecDirect(hstmt,abb,-3);
	result = SQLFetch(hstmt);
while (result == SQL_SUCCESS)
{
SQLGetData(hstmt, 1,SQL_INTEGER,&idno,sizeof(idno),&l);
SQLGetData(hstmt, 2,SQL_C_CHAR,titlestr,sizeof(titlestr),&l);
SQLGetData(hstmt, 3,SQL_C_CHAR,fnamestr,sizeof(fnamestr),&l);
SQLGetData(hstmt, 4,SQL_C_CHAR,desigstr,sizeof(desigstr),&l);
SQLGetData(hstmt, 5,SQL_C_CHAR,companystr,sizeof(companystr),&l);
SQLGetData(hstmt, 6,SQL_C_CHAR,addressstr,sizeof(addressstr),&l);
SQLGetData(hstmt, 7,SQL_C_CHAR,telestr,sizeof(telestr),&l);
SQLGetData(hstmt, 8,SQL_C_CHAR,faxstr,sizeof(faxstr),&l);
SQLGetData(hstmt, 9,SQL_C_CHAR,emailstr,sizeof(emailstr),&l);
SQLGetData(hstmt, 10,SQL_C_CHAR,flagstr,sizeof(flagstr),&l);
SQLGetData(hstmt, 11,SQL_C_CHAR,qualistr,sizeof(qualistr),&l);
SQLGetData(hstmt, 12,SQL_INTEGER,&prgmno,sizeof(prgmno),&l);
SQLGetData(hstmt, 13,SQL_INTEGER,&analno,sizeof(analno),&l);
SQLGetData(hstmt, 14,SQL_INTEGER,&prjmgmtno,sizeof(prjmgmtno),&l);
SQLGetData(hstmt, 15,SQL_C_CHAR,workareastr,sizeof(workareastr),&l);
SQLGetData(hstmt, 16,SQL_C_CHAR,toolstr,sizeof(toolstr),&l);
SQLGetData(hstmt, 17,SQL_C_CHAR,osstr,sizeof(osstr),&l);
SQLGetData(hstmt, 18,SQL_C_CHAR,expstr,sizeof(expstr),&l);
printf("ID No. %d<p>",idno);
if (flagstr[0] == 'Y')
{
	printf("<b>Title</b>		: %s<br>",titlestr);
	printf("<b>Name	</b>	: %s<br>",fnamestr);
	printf("<b>Designation</b>	: %s<br>",desigstr);
	printf("<b>Company</b>		: %s<br>",companystr);
	printf("<b>Address</b>		: %s<br>",addressstr);
	printf("<b>Telephone </b>  : %s<br>",telestr);
	printf("<b>Fax</b>			: %s<br>",faxstr);
	printf("<b>Email</b>		: %s<br>",emailstr);
}
	printf("<b>Qualification</b>: %s<br>",qualistr);
	printf("<b>Experience</b> :<br>");
	
	if (prgmno !=0)
	printf("<b>Programming</b> : %d<br>",prgmno);
	if (analno!=0)
	printf("<b>Analysis</b>	: %d<br>",analno);
	if (prjmgmtno !=0)
	printf("<b>Project Management</b>: %d<br>",prjmgmtno);
	printf("<b>Areas Of Work</b>: %s<br>",workareastr);
	printf("<b>Tools</b>: %s<br>",toolstr);
	printf("<b>Operating Systems</b>: %s<br>",osstr);
	printf("<b>Expert in </b>: %s<br>",expstr);
	printf("<p><hr>");
	
	result = SQLFetch(hstmt);
}
	
SQLFreeStmt(hstmt,SQL_DROP);
SQLDisconnect(hdbc);
SQLFreeConnect(hdbc);
SQLFreeEnv(henv);
puts("</body></html>");	
}
Back to  CGI Page
Back to the Cornucopia Page
Vijay Mukhi's Computer
Institute
VMCI, B-13, Everest Building, Tardeo, Mumbai 400 034, India
Tel : 91-22-496 4335 /6/7/8/9    
Fax : 91-22-307 28 59 
e-mail : vmukhi@giasbm01.vsnl.net.in
http://www.vijaymukhi.com