我用VC+ADO,Excel做后台数据库. CString m_strConnection;
m_pConn.CreateInstance(__uuidof(Connection));
m_strConnection = "Driver={Microsoft Excel Driver (*.xls)};Dbq=";
m_strConnection+=m_strpath;
m_strConnection+=";Uid=ohahu;Pwd=ohahu";
m_pConn->Open(_bstr_t(m_strConnection),"","",adConnectUnspecified);用以上代码连接Excel数据库。连接了一个Excel空白的表,一般比如写入ACCESS数据库时,都用 m_pRecordset2->PutCollect("NoteText",vNoteText);NoteText是字段名。但在Excel表中,还没有字段名,也没写入第一行内容时(空白表),我该样写入呢数据呢?请各位高人指点!分不够再加!!PS:VCBASE的那个ODBC的例子俺看过了,各位就不用给出了,如果可以请给出ADO写Excel的例子,谢谢!
m_pConn.CreateInstance(__uuidof(Connection));
m_strConnection = "Driver={Microsoft Excel Driver (*.xls)};Dbq=";
m_strConnection+=m_strpath;
m_strConnection+=";Uid=ohahu;Pwd=ohahu";
m_pConn->Open(_bstr_t(m_strConnection),"","",adConnectUnspecified);用以上代码连接Excel数据库。连接了一个Excel空白的表,一般比如写入ACCESS数据库时,都用 m_pRecordset2->PutCollect("NoteText",vNoteText);NoteText是字段名。但在Excel表中,还没有字段名,也没写入第一行内容时(空白表),我该样写入呢数据呢?请各位高人指点!分不够再加!!PS:VCBASE的那个ODBC的例子俺看过了,各位就不用给出了,如果可以请给出ADO写Excel的例子,谢谢!
能给我发一份吗:[email protected]
谢谢
发了,请查收!
{
CString S1="SELECT * FROM Addressbook"; m_pRecordset2.CreateInstance("ADODB.Recordset");
m_pRecordset2->Open((_variant_t)S1,_variant_t((IDispatch*)m_pConn,true),/*adOpenDynamic*/adOpenStatic,adLockOptimistic,adCmdText);
m_pRecordset2->AddNew(); m_pRecordset2->PutCollect("A",_variant_t(Stext) );
m_pRecordset2->Update();连接成功后,用以上方法根本就不行. 错误信息是:没有"A"这个字段名的存在!