iCAx开思工具箱
标题:
动态建立ACESS表
[打印本页]
作者:
whllenny
时间:
2006-6-11 20:34
标题:
动态建立ACESS表
各位高手,
我用ADO动态建立ACESS表时,为什么只能建四列,到了第五列,编译连接都可以,一用UG调用就不行了,出错,为什么啊?谁有解决方案?
程序:
_ConnectionPtr m_pConnection;
m_pConnection.CreateInstance("ADODB.Connection");
m_pConnection->Open("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=E:\\project\\base\\mingxi\\mingxibiao.mdb","","",adModeUnknown);
_RecordsetPtr m_pRecordset;
_variant_t RecordsAffected;
m_pConnection->Execute("CREATE TABLE 3_g_01(ID INTEGER NOT NULL,partname TEXT,attribute INTEGER)",
&RecordsAffected,adCmdText);
m_pConnection->Execute("ALTER TABLE 3_g_01 ADD count INTEGER",&RecordsAffected,adCmdText);
m_pRecordset.CreateInstance("ADODB.Recordset");
m_pRecordset->Open("SELECT * FROM 3_g_01",_variant_t((IDispatch *)m_pConnection,true),adOpenStatic,adLockOptimistic,adCmdText);
m_pRecordset->AddNew();///添加新记录
m_pRecordset->PutCollect("ID",_variant_t(long(1)));
m_pRecordset->PutCollect("partname",_variant_t("157.74.01.01c"));
m_pRecordset->PutCollect("attribute",_variant_t(long(450)));
m_pRecordset->PutCollect("count",_variant_t(long(1)));
m_pRecordset->Update();
m_pRecordset->Close();//关闭记录集
m_pConnection->Close();//关闭连接
欢迎光临 iCAx开思工具箱 (https://t.icax.org/)
Powered by Discuz! X3.3