我用DAO:
CDaoDatabase db;
db.Create(DbName);
CDaoTableDef tbf(&db);
tbf.Create("index_table");
tbf.CreateField("序号",dbLong,dbAutoIncrField);
tbf.CreateField("产品型号",dbText,40,dbVariableField);
tbf.CreateField("出厂序号",dbText,20,dbVariableField);
tbf.CreateField("日期",dbText,20,dbVariableField);
tbf.CreateField("时间",dbText,20,dbVariableField);
tbf.CreateField("评价",dbText,20,dbVariableField);
tbf.CreateField("状态",dbByte,1,dbVariableField);
tbf.CreateField("测试数据库路径",dbText,80,dbVariableField);
CDaoIndexInfo indexinfo;
CDaoIndexFieldInfo indexfieldinfo;
indexfieldinfo.m_bDescending=FALSE;
indexfieldinfo.m_strName="序号";
indexinfo.m_bPrimary=TRUE;
indexinfo.m_strName="序号";
indexinfo.m_nFields=1;
indexinfo.m_pFieldInfos=&indexfieldinfo;
tbf.CreateIndex(indexinfo);
tbf.Append();
tbf.Close();
db.Close()
CDaoDatabase db;
db.Create(DbName);
CDaoTableDef tbf(&db);
tbf.Create("index_table");
tbf.CreateField("序号",dbLong,dbAutoIncrField);
tbf.CreateField("产品型号",dbText,40,dbVariableField);
tbf.CreateField("出厂序号",dbText,20,dbVariableField);
tbf.CreateField("日期",dbText,20,dbVariableField);
tbf.CreateField("时间",dbText,20,dbVariableField);
tbf.CreateField("评价",dbText,20,dbVariableField);
tbf.CreateField("状态",dbByte,1,dbVariableField);
tbf.CreateField("测试数据库路径",dbText,80,dbVariableField);
CDaoIndexInfo indexinfo;
CDaoIndexFieldInfo indexfieldinfo;
indexfieldinfo.m_bDescending=FALSE;
indexfieldinfo.m_strName="序号";
indexinfo.m_bPrimary=TRUE;
indexinfo.m_strName="序号";
indexinfo.m_nFields=1;
indexinfo.m_pFieldInfos=&indexfieldinfo;
tbf.CreateIndex(indexinfo);
tbf.Append();
tbf.Close();
db.Close()
解决方案 »
- 响应函数
- 急急急
- 输入自相交的折线,如何计算其围成的所有多边形的面积之和
- 请问我怎么才能传递一个RecordSet?
- 我想在List control控件中加入排序的图标,象Winzip那样的,应该怎么加呢?
- 急!请问各位前辈,如何把一个按钮(Button)标题的字体改变?
- 能不能用ADOX来创建FOXPRO数据库,怎么创建它
- 有用过file mapping的么,请指教一二
- 招聘启示5000/月程序员
- 写了个简单的字符串反转函数,总出现0xC0000005: Access Violation问题,求大神指点
- 拉伸位图怎么做?
- 使用CWin::SetDlgItemText()函数怎么不成功,请举个例子给我看看
int mlen;
szDesc=new char[256];
CString strpath;
strpath = dbfile_name;
while((CString)(strpath.GetAt(strpath.GetLength()-1))!="\\")
{
strpath.Delete(strpath.GetLength()-1,1);
}
strpath.Delete(strpath.GetLength()-1,1);sprintf(szDesc,"DSN=%s^ DESCRIPTION=TOC support source^ DBQ=%s^ FIL=MicrosoftAccess^ DEFAULTDIR=%s^^",
"MyDB",dbfile_name,strpath);
mlen = strlen(szDesc);for (int i=0; i<mlen; i++)
{
if (szDesc[i] == '^')
szDesc[i] = '\0';
}if (FALSE == SQLConfigDataSource(NULL,ODBC_ADD_DSN,"Microsoft Access Driver (*.mdb)\0",(LPCSTR)szDesc))
{
MessageBox("Failed","INFORMATION",MB_OK);
return;
}
//else
// MessageBox("Sucess","INFORMATION",MB_OK);
m_MsGrid.ClearFields();
m_MsGrid.SetCaption(dbfile_name);
m_Rdc.SetDataSourceName(_T("MyDB"));
m_Rdc.SetSql(_T("select * from 产品测试数据表"));
m_Rdc.SetUserName(_T(""));
m_Rdc.SetPassword(_T(""));
m_Rdc.SetCaption(m_gDb_path);
m_Rdc.SetCursorDriver(0);
m_Rdc.Refresh();