资源描述:
《c语言连接数据库的代码》由会员上传分享,免费在线阅读,更多相关内容在应用文档-天天文库。
1、附一源码CWinApptheApp;usingnamespacestd;CHmbAdoDBRsRfRst;CStringsSql;CStringseq,body,eng,tm,tl,icol,ecol,alc,bhmcdate;inti;BOOLDbOpen();BOOLCkseqtmpSelect();BOOLCkseqtmpUpdate();intPrintStatus();intSockInit();CHmbAdoDBSqldb;int_tmain(intargc,TCHAR*argv[],TCHA
2、R*envp[]){intcnt=0;intnRetCode=0;intpage=1;intprt_ret;CStringstrDate,strTime;//initializeMFCandprintanderroronfailureif(!AfxWinInit(::GetModuleHandle(NULL),NULL,::GetCommandLine(),0)){//TODO:changeerrorcodetosuityourneedscerr<<_T("FatalError:MFCinitializa
3、tionfailed")<4、MPFLAG03='0'SELECTSleep(3000);continue;}while(1){//PRINTERSTATUSCheckprt_ret=PrintStatus();if(prt_ret==1){closesocket(sid);WSACleanup();while(1){ret=SockInit();if(ret<0)Sleep(3000);elsebreak;}break;}else{printf("PrinterStatusCheck!!!");Sleep(3000);}}pri
5、ntf("%s-%s-%s-%s-%s-%s-%s-%s-%s",seq,body,eng,tm,tl,icol,ecol,alc,bhmcdate);memset(sbuf,0x00,sizeof(sbuf));sprintf(sbuf,"%c%c1",ESC,W);ret=send(sid,sbuf,strlen(sbuf),0);if(cnt==0
6、
7、atoi(seq)<2){if(atoi(seq)<2){cnt=0;page=1;memset(sbuf,0x00,sizeof(sbuf));
8、sprintf(sbuf,"%c%c%c",FF,CR,LF);ret=send(sid,sbuf,strlen(sbuf),0);}memset(sbuf,0x00,sizeof(sbuf));sprintf(sbuf,"[BUMPERASS'YWORKORDER]%c%c%c%c%c%c",CR,LF,CR,LF,CR,LF);ret=send(sid,sbuf,strlen(sbuf),0);strDate.Format("%s-%s-%s",bhmcdate.Left(4),bhmcdate.Mi
9、d(4,2),bhmcdate.Mid(6,2));memset(sbuf,0x00,sizeof(sbuf));sprintf(sbuf,"PAGE:%3dDATE:%s%c%c",page,strDate,CR,LF);ret=send(sid,sbuf,strlen(sbuf),0);memset(sbuf,0x00,sizeof(sbuf));//123456789/123456789/123456789/123456789/123456789/12345678901234567890123456
10、78901234567890sprintf(sbuf,"========================================================%c%c",CR,LF);ret=send(sid,sbuf,strlen(sbuf),0);memset(sbuf,0x00,sizeof(sbuf));sprintf(sbuf,"SEQBODYNOBUMPECOLT/LENGBHMCTIME%c%c%c%c