January 20th, 2009, 10:52 AM
[RESOLVED] Using ADO in VS2005
This is my first time ever working with anything database related and I am having problems. I am trying to access a Microsoft Access Database that is stored locally on my machine, read some tables and extract the data. The code worked fine initially using DAO but I have been tasked to convert it so something not deprecated and I thought this ADO was the correct option.
I have been using the following article as my reference since it is the only one I found that speaks in C++ terms.
I have attached my ADO "wrapper" classes for reference. Pasted below is a code excerpt of me trying to open the database, access a table and extract some info. I am unable to connect to my database, what am I doing wrong? Any constructive advice is welcome, thank you.
// Open the database to access all the data to be written to the data files
if (DatabaseFileName == "")
DbName = GetDefaultDBName(); // Set database name for all tables
DbName = DatabaseFileName;
char CnnStr="Provider=Microsoft.Jet.OLEDB.4.0;Persist Security Info=False;"\
"User ID=null;Initial Catalog=pubs;Data "\
"Source=C:\Travis_Thread\tenpc\ten\Data\TEN Data Tables.mdb" ;
TEN_Database.Open(NULL, NULL, CnnStr);
TEN_Database.Execute("SELECT * FROM Classification", ClassTable);
ClassInfo = new TClass;
ClassTable.Get( "[Classification Index]", m_Index);
ClassTable.Get( "[Classification]", m_Classification.GetBuffer());
ClassTable.Get( "[Derived From]", m_DerivedFrom.GetBuffer());
ClassTable.Get( "[Declass On]", m_DeclassOn.GetBuffer());
ClassTable.Get( "[Downgrade To]", m_DowngradeTo.GetBuffer());
ClassTable.Get( "[Date Of Source]", m_DateOfSource.GetBuffer());
ClassInfo->Index = m_Index;
ClassInfo->Class = m_Classification;
ClassInfo->DerivedFrom = m_DerivedFrom;
ClassInfo->DeclassOn = m_DeclassOn;
ClassInfo->DowngradeTo = m_DowngradeTo;
ClassInfo->DateOfSource = m_DateOfSource;
Last edited by Draznar; January 20th, 2009 at 11:57 PM.
Reason: Added a missing Struct
Tags for this Thread
Click Here to Expand Forum to Full Width
This is a Codeguru.com survey!