用vc通过ado与access相连接:
void CMyDataDlg::OnAddtable()
{
variant_t RecordsAffected;
m_pConnection->Execute("CREATE TABLE new(ID INT,Old INT,Name CHAR,depiction CHAR)",&RecordsAffected1,adCmdText); ////ID为主键,Old是外键
}
我想同时再建一张表 CREATE TABLE new1(Old INT ,Time INT...........)///Old是主键应该怎么办???
void CMyDataDlg::OnAddtable()
{
variant_t RecordsAffected;
m_pConnection->Execute("CREATE TABLE new(ID INT,Old INT,Name CHAR,depiction CHAR)",&RecordsAffected1,adCmdText); ////ID为主键,Old是外键
}
我想同时再建一张表 CREATE TABLE new1(Old INT ,Time INT...........)///Old是主键应该怎么办???
它就提示错误:
runtime error!
This application has requested the runtime to terminate it in an unusual way.
Please contact the applicatin's support team for more imformation
我在另外一个函数里执行也是同样提示!无法创建 !
后加上m_pConnection->Close();
m_pConnection->Release();也是不能在创建!
你可以这样试试
CString strCreateTable;
for(int i=0;i<=n;i++)
{
strCreateTable.Format("CREATE TABLE new%d(ID INT,Old INT,Name CHAR,depiction CHAR",i);
m_pConnection->Execute((LPCSTR)strCreateTable,&RecordsAffected,adCmdText);
}