Quantcast
Channel: LabWindows/CVI topics
Viewing all articles
Browse latest Browse all 5339

Database disconnected problem

$
0
0

I built a Labwindows project and paste it to the remote desk.But the database cannot connect. Here is my code. They say that it is the problem is relating to different version of CVI. I use Labwindows 2009, but I tried again using Labwindows 8.5, I failed again.

 

main code:

include <windows.h>//我们需要WINDOWS的API函数
#include <stdio.h>
#include <stdlib.h>

#include <formatio.h>
#include "toolbox.h"
//#include "asynctmr.h"
#include <ansi_c.h>
#include <tcpsupp.h>
#include <cvirte.h> /* Needed if linking in external compiler; harmless otherwise */
#include <userint.h>
#include "cvi_db.h"
#include <utility.h>

#include "server.h"

#define ZUIJIN_200 3000
#define ZUIJIN_125 2800

typedef BOOL DLLEXPORT (*DLLCdeclFunction)(int,int,int);//定义函数指针
typedef BOOL DLLEXPORT (*DLLCdeclFunction2)(float*,int,float,BOOL,int);//定义函数指针

int flg=0;
//static int panel;
static int panelHandle;
int ConnectedHandle;
int resCode;
int resultcode;
static int hdbc;
int j=0;
int i;
unsigned int port=2000;
unsigned char id[11]={0};

unsigned ConnectedHandle1=0;
//unsigned ConnectedHandle2=0;


int *flag1={0} ;
int *flag2={0} ;



int max1=0;
int max2=0;

int flag_1[ZUIJIN_125]={0};
int flag_2[ZUIJIN_125]={0};


//要数队列全局变量
int yaoshuduilie_1[1000]={0}; //hubei_test1表缺数队列
int yaoshu_count1=0; //hubei_test1缺数队列中的数量
int yaoshuduilie_2[1000]={0}; //hubei_test2表缺数队列
int yaoshu_count2=0; //hubei_test2缺数队列中的数量

 

// 全局变量,存储上一次发送的命令
//************************
char buftemp_1[150]={""};
char buftemp_2[150]={""};

//************************

//全局变量记录心跳次数
int xintiao_count1=0;
int xintiao_count2=0;


int sscrc=5; //校验用返回值
int cscrc=0; //校验用返回值
//服务器回调函数
int CVICALLBACK ServerCallback1(unsigned handle, int event,
int error, void *callbackData);
//int CVICALLBACK ServerCallback2(unsigned handle, int event,
//int error, void *callbackData);

int send2 (int biaoduan,int ConnectedHandle);
int send1 (int* sflag,int max,int ConnectedHandle);

//*********************************************
int dxl_send1 (int* sflag,int max,int ConnectedHandle,int biaoduan);
int csx_send1 (int yaoshu_count,int* yaoshuduilie,int ConnectedHandle,int biaoduan);
int* search (int bd);


unsigned short int crc(unsigned char *ptr,unsigned char len)
{
unsigned char i;
unsigned short int crc=0;
while((len--)!=0)
{
for(i=0x80;i!=0;i/=2)
{
if((crc&0x8000)!=0)
{
crc*=2;
crc^=0x1021;
}
else
crc*=2;
if((*ptr&i)!=0)
crc^=0x1021;
}
ptr++;
}
return(crc);
}

 


int main (int argc, char *argv[])
{
char barcode[50]={"012345"};
if (InitCVIRTE (0, argv, 0) == 0) /* Needed if linking in external compiler; harmless otherwise */
return -1; /* out of memory */

if ((panelHandle = LoadPanel (0, "server.uir", PANEL)) < 0)
return -1;
DisplayPanel (panelHandle);
RegisterTCPServer (3127, ServerCallback1, 0); //注册服务器,端口6060做好连接准备 //9.4 rectify
// RegisterTCPServer (6061, ServerCallback2, 0); //注册服务器,端口1006好连接准备



//MessagePopup("警告!","没有连接数据库!");
resCode=DBInit(DB_INIT_MULTITHREADED); //连接数据库
hdbc=DBConnect("DSN=WLLTEST");
if(hdbc<=0)
{
MessagePopup("警告!","数据库连接失败!");
return 0;
}

RunUserInterface ();

DBDisconnect(hdbc);//关闭数据库
DiscardPanel (panelHandle);
return 0;
}

 

errors while running in my computer:

 

ADM6RT~O02NR4SKRDUQ3{%A.jpg

errors while click the exe file in the remote desk:

popup the message:"警告!","数据库连接失败! which means database disconnect in English.

I will be very grateful if anyone can help me solve the problem. Thank U very much!!!


Viewing all articles
Browse latest Browse all 5339

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>