the code is
Expand|Select|Wrap|Line Numbers
- # include<iostream.h>
- #include<stdlib.h>
- #include<fstream.h>
- #include<string.h>
- # include<conio.h>
- class lib
- {
- protected:
- int reg_no[10],year[10],no_cards[10];
- char name[20][20],dept[10][10];
- static int count;
- clrscr();
- public:
- void create_lib();
- void del(int);
- void disp_lib();
- int search(int);
- static void showcount()
- {
- cout<<"no of people registered"<<count<<"\n";
- }
- getch();
- };
- int lib::count;
- void lib::create_lib()
- {
- count++;
- cout<<"enter the name \n:";
- cin>>name[count];
- cout<<"enter the register number \n";
- cin>>reg_no[count];
- cout<<"enter the department \n";
- cin>>dept[count];
- cout<<"enter the year \n";
- cin>>year[count];
- cout<<"enter the number of cards \n";
- cin>>no_cards[count];
- }
- void lib::disp_lib()
- {
- for(int i=1;i<=count;i++)
- {
- cout<<"name::"<<name[i]<<"\n";
- cout<<"reg_no::"<<reg_no[i]<<"\n";
- cout<<"dept::"<<dept[i]<<"\n";
- cout<<"year ::"<<year[i]<<"\n";
- cout<<"No_cards:: "<<no_cards[i]<<"\n";
- }
- }
- void lib::del(int a)
- {
- for(int i=a;i<=count;i++)
- {
- reg_no[i+1]=reg_no[i];
- year[i+1]=year[i];
- no_cards[i+1]=no_cards[i];
- strcpy(name[i+1],name[i]);
- strcpy(dept[i+1],dept[i]);
- }
- count--;
- cout<<"successfully deleted";
- }
- int lib::search(int code)
- {
- int pos=0,flag=0;
- for(int i=1;i<count;i++)
- {
- if(reg_no[i]==code)
- {
- pos=1;
- flag=1;
- }}
- if(flag!=1)
- pos=0;
- return(pos);
- }
- class boo
- {
- protected:
- int dept_code[10],no_copy[10],book_code[10];
- char name_boo[50][50],author[20][20],pub[10][10];
- static int coun;
- clrscr();
- public:
- void create_boo();
- void disp_boo();
- int search(int);
- static void showcoun()
- {
- cout<<"no of books"<<coun<<"\n";
- }
- getch();
- };
- int boo::coun;
- void boo::create_boo()
- {
- coun++;
- cout<<"enter the name of the book"<<"\n";
- cin>>name_boo[coun];
- cout<<"enter the department code"<<"\n";
- cin>>dept_code[coun];
- cout<<"enter the book code"<<"\n";
- cin>>book_code[coun];
- cout<<"enter the author name"<<"\n";
- cin>>author[coun];
- cout<<"enter the publishing name"<<"\n";
- cin>>pub[coun];
- cout<<"enter the no of copies"<<"\n";
- cin>>no_copy[coun];
- }
- void boo::disp_boo()
- {
- for(int i=1;i<=coun;i++)
- {
- cout<<"name_boo :: " <<name_boo[i]<<"\n";
- cout<<"dept_cod :: "<<dept_code[i]<<"\n";
- cout<<"book_code :: "<<book_code[i]<<"\n";
- cout<<"auth_name :: "<<author[i]<<"\n";
- cout<<"pub_name ::"<<pub[i]<<"\n";
- cout<<"no_copies :: "<<no_copy[i]<<"\n\n\n";
- }
- }
- int boo::search(int code)
- {
- int pos=0,flag=0;
- for(int i=1;i<=coun;i++)
- {
- if(book_code[i]==code)
- {
- pos=1;
- flag=1;
- }
- }
- if(flag!=1)
- pos=0;
- return(pos);
- }
- class len:public boo,public lib
- {
- int re[10];
- char na[50][50];
- public:
- void check(void);
- void time();
- };
- void len::check(void)
- {
- lib::disp_lib();
- boo::disp_boo();
- cout<<"enter the reg_no"<<"\n";
- cin>>re[coun];
- for(int i=1;i<=coun;i++)
- {
- if(reg_no[i]==re[i])
- {
- cout<<"enter the book name"<<"\n";
- cin>>na[coun];
- for(int i=1;i<=coun;i++)
- {
- if(name_boo[i]==na[i])
- {
- boo::disp_boo();
- no_copy[coun]=no_copy[coun]-1;
- cout<<no_copy[coun];
- }
- else
- {
- cout<<"enter the correct book name"<<"\n";
- }
- }
- }
- else
- {
- cout<<"enter the valid data"<<"\n";
- }}}
- void len::time()
- {
- int dd,mm,yy,dd1,mm1,yy1;
- cout<<"enter the date of issue"<<"\n";
- cin>>dd>>mm>>yy;
- cout<<"enter the date of return"<<"\n";
- cin>>dd1>>mm1>>yy1;
- cout<<"date of issue \t:"<<dd<<"/"<<mm<<"/"<<yy<<"\n\n";
- cout<<"date of return\t:"<<dd1<<"/"<<mm1<<"/"<<yy1<<"\n";
- }
- void main()
- {
- int s=1,x,temp,t,y,z,v;
- boo q;
- lib p;
- len f;
- do
- {
- cout<<"1.Member details\n 2.book details\n 3.lending form\n 4.exit \n";
- cin>>y;
- switch(y)
- {
- case 1:
- cin>>x;
- switch(x)
- {
- case 1:
- p.create_lib();
- break;
- case 2:
- cout<<"enter the reg_no\n";
- cin>>temp;
- t=0;
- t=p.search(temp);
- if(t>0)
- p.del(t);
- else
- cout<<"register number not found!!!! please enter the valid number\n ";
- break;
- case 3:
- lib::showcount();
- p.disp_lib();
- break;
- case 4:
- s=0;
- break;
- }
- break;
- cout<<"\n 1.member details\n2.book details\n3.lending form\n4.exit\n\n ";
- cin>>y;
- case 2:
- cout<<"\nbook details\n1.create\n2.search\n3.display\n4.exit\n";
- cin>>z;
- switch(z)
- {
- case 1:
- q.create_boo();
- break;
- case 2:
- cout<<"enter the code no\n";
- cin>>temp;
- t=0;
- t=q.search(temp);
- if(t>0)
- cout<<"book is found\n";
- else
- cout<<"book not found!!!! pls enter the present book name";
- break;
- case 3:
- boo::showcoun();
- q.disp_boo();
- break;
- case 4:
- s=0;
- break;
- }
- break;
- cout<<"\n 1.member details\n 2.book details\n 3.lending form\n4.exit ";
- cin>>y;
- case 3:
- cout<<"1.get the book\n2.rem time\n3.exit";
- cin>>v;
- switch(v)
- {
- case 1:
- f.check();
- break;
- case 2:
- f.time();
- break;
- case 3:
- s=0;
- break;
- }
- break;
- case 4:
- s=0;
- break;
- }
- }
- while(s==1);
- }
it is working
but i want to know can i able to connect this program with ms access
if it is possible means how can i do that
can any one help me
and i have one program in vc++,that is used to connect to database.
can i use that code here.
if it ok how can i do.this is my project in college can any one help
vc++ coding is
Expand|Select|Wrap|Line Numbers
- #include<windows.h>
- #include<sqlext.h>
- #include<iostream.h>
- int main(void)
- {
- HENV hEnv = NULL;
- HDBC hDBC = NULL;
- HSTMT hStmt= NULL;
- UCHAR szDSN[SQL_MAX_DSN_LENGTH] = "ds97";
- UCHAR* szUID = NULL;
- UCHAR* szPasswd = NULL;
- UCHAR szModel[128];
- SDWORD cbModel;
- UCHAR szSqlStr[] = "Select name from table1";
- RETCODE retcode;
- SQLAllocEnv(&hEnv);
- SQLAllocConnect(hEnv,&hDBC);
- retcode = SQLConnect(hDBC, szDSN,SQL_NTS,szUID,SQL_NTS,szPasswd,SQL_NTS);
- HSTMT hStmt1 = NULL;
- UCHAR szModel1[128];
- SDWORD cbModel1;
- UCHAR szSqlStr1[] = "Select accno from table1";
- RETCODE retcode1;
- retcode1 = SQLConnect(hDBC,szDSN,SQL_NTS,szUID,SQL_NTS,szPasswd,SQL_NTS);
- HSTMT hStmt2 = NULL;
- UCHAR szModel2[128];
- SDWORD cbModel2;
- UCHAR szSqlStr2[] = "Select addr from table1";
- RETCODE retcode2;
- retcode2 = SQLConnect(hDBC,szDSN,SQL_NTS,szUID,SQL_NTS,szPasswd,SQL_NTS);
- HSTMT hStmt3 = NULL;
- UCHAR szModel3[128];
- SDWORD cbModel3;
- UCHAR szSqlStr3[] = "Select balance from table1";
- RETCODE retcode3;
- retcode3 = SQLConnect(hDBC,szDSN,SQL_NTS,szUID,SQL_NTS,szPasswd,SQL_NTS);
- if(retcode == SQL_SUCCESS||retcode == SQL_SUCCESS_WITH_INFO &&
- retcode1 == SQL_SUCCESS || retcode1 == SQL_SUCCESS_WITH_INFO)
- {
- retcode =SQLAllocStmt(hDBC,&hStmt);
- retcode = SQLPrepare(hStmt,szSqlStr, sizeof(szSqlStr));
- retcode = SQLExecute(hStmt);
- SQLBindCol(hStmt, 1,SQL_C_CHAR,szModel,sizeof(szModel),&cbModel);
- retcode = SQLFetch(hStmt);
- retcode1 =SQLAllocStmt(hDBC,&hStmt1);
- retcode1 = SQLPrepare(hStmt1,szSqlStr1, sizeof(szSqlStr1));
- retcode1 = SQLExecute(hStmt1);
- SQLBindCol(hStmt1, 1,SQL_C_CHAR,szModel1,sizeof(szModel1),&cbModel1);
- retcode1 = SQLFetch(hStmt1);
- retcode2 =SQLAllocStmt(hDBC,&hStmt2);
- retcode2 = SQLPrepare(hStmt2,szSqlStr2, sizeof(szSqlStr2));
- retcode2 = SQLExecute(hStmt2);
- SQLBindCol(hStmt2, 1,SQL_C_CHAR,szModel2,sizeof(szModel2),&cbModel2);
- retcode2 = SQLFetch(hStmt2);
- retcode3 =SQLAllocStmt(hDBC,&hStmt3);
- retcode3 = SQLPrepare(hStmt3,szSqlStr3, sizeof(szSqlStr3));
- retcode3 = SQLExecute(hStmt3);
- SQLBindCol(hStmt3, 1,SQL_C_CHAR,szModel3,sizeof(szModel3),&cbModel3);
- retcode3 = SQLFetch(hStmt3);
- while(retcode == SQL_SUCCESS || retcode == SQL_SUCCESS_WITH_INFO)
- {
- cout<<szModel1<<"\t\t"<<szModel<<"\t\t"<<szModel2<<"\t\t\t"
- <<szModel3<<"\n";
- retcode = SQLFetch(hStmt);
- retcode1 = SQLFetch(hStmt1);
- retcode2 = SQLFetch(hStmt2);
- retcode3 = SQLFetch(hStmt3);
- }
- SQLFreeStmt(hStmt,SQL_DROP);
- SQLFreeStmt(hStmt1,SQL_DROP);
- SQLFreeStmt(hStmt2,SQL_DROP);
- SQLFreeStmt(hStmt3,SQL_DROP);
- SQLDisconnect(hDBC);
- }
- SQLFreeConnect(hDBC);
- SQLFreeEnv(hEnv);
- return 0;
- }