急!请高手指点!
vb 如何生成一.dbf的数据库,怎么往生成的数据库中添加数据。有四个字段,谢谢!
--------------------编程问答--------------------
参考这个可能有用
#include <stdio.h>
#include <string.h>
#include <share.h>
#include <conio.h>
//-------------------------------------------------------
typedef struct HeadOfDbf {
unsigned char tab;
unsigned char year;
unsigned char month;
unsigned char day;
unsigned long recnum;
unsigned int offset;
unsigned int reclen;
char save[20];
} InfoOfDbfHead;
typedef struct HeadOfDbfIndex {
unsigned char fname[11];
unsigned char type;
long addr;
unsigned char width;
unsigned char doc;
char save[14];
} InfoOfDbfIndex;
InfoOfDbfHead Head;
InfoOfDbfIndex Index[48];
int offset[48],n;
FILE *fdbf;
unsigned int rec,field,fieldnum,i;
char buf[128];
//-------------------------------------------------------
void main(int argc,char *argv[])
{
if (argc==1) {
cprintf("DBF name[.DBF]");
return;
}
strcpy(buf,argv[1]);
strcat(buf,".dbf");
if ((fdbf=_fsopen(buf,"r+b",SH_DENYNO))==NULL) {
cprintf("db_open error");
return;
}
fseek(fdbf,0L,SEEK_SET);
fread(&Head,sizeof(InfoOfDbfHead),1,fdbf);
fieldnum=(Head.offset-1)/32-1;
fseek(fdbf,32,SEEK_SET);
n=0;
for(i=0;i<fieldnum;i++) {
offset[i]=n;
fread(&Index[i],sizeof(InfoOfDbfIndex),1,fdbf);
n=n+Index[i].width;
}
for (rec=0;rec<Head.recnum;rec++) {
printf("\n?);
for (field=0;field<fieldnum;field++) {
fseek(fdbf,(long)(Head.offset+1+rec*(long)Head.reclen+offset[field]),SEEK_SET);
fread(buf,1,Index[field].width,fdbf);
buf[Index[field].width]=0;
printf("%s?,buf);
}
}
fclose(fdbf);
}
补充:VB , 非技术类