Re: Cannot read data from Access 2007 database



dbouthillier wrote:
if (SUCCEEDED(m_oRecordSet->Open("Select * FROM Table1",

A couple things to try:
Explicitly name the fields you want to return from Table1 instead of
using selstar (select * ). Make sure that if you have made the mistake
of using reserved keywords (such as "date") for your field names that
you surround them with brackets [] (better yet - go rename them) -
select [date], ...

Make sure you test the recordset's EOF property before attempting to
work with any data

m_oDatabase.GetInterfacePtr(), adOpenDynamic, adLockOptimistic,
adCmdText))) {
if (SUCCEEDED(m_oRecordSet->MoveFirst()))

This is unnecessary - if the recordset contains records, it will already
be pointing at the first record upon opening. You should be testing for
EOF at this point

{
_variant_t value =
m_oRecordSet->Fields->GetItem("DATE")->Value; }

You should not have to use brackets around DATE here - only in the sql
statement.

If you still have problems, loop through the Fields collection and make
sure the field names are what you expect them to be.

--
Microsoft MVP -- ASP/ASP.NET
Please reply to the newsgroup. The email account listed in my From
header is my spam trap, so I don't check it very often. You will get a
quicker response by posting to the newsgroup.


.



Relevant Pages

  • Re: Median calculation
    ... Already answered in another newsgroup to which you posted the same question. ... Dim rs As DAO.Recordset ... 'Open a recordset on the table. ... DMedian = rs ...
    (microsoft.public.access.queries)
  • Re: Access sending data to Word VBA Userform
    ... To get assistance on that, it would be best to ask in an Access newsgroup, ... Doug Robbins - Word MVP ... Dim rs As DAO.Recordset ... ' Set the number of Columns = number of Fields in recordset ...
    (microsoft.public.word.vba.userforms)
  • Re: Binding Data to Forms, Textboxes etc.
    ... I intended to post this to the .net forms newsgroup, and yes I may be mixing ... > Windows applications are a very different animal to Access forms. ... The terms 'Row Source' and 'Recordset' are not used ... >> "A bound form means that you have identified a Row Source for your form. ...
    (microsoft.public.access.formscoding)
  • Re: DSN Less Connection to SQL Server
    ... Simply remove the word "server." ... > ' Use the diconnected recordset here. ... >> Bob Barrows ... >> a quicker response by posting to the newsgroup. ...
    (microsoft.public.scripting.vbscript)
  • Re: ASP Tables + strange stuff
    ... This is the ASP.Net newsgroup. ... > Set objRS = Nothing ... > The actual code invloves alot more columns/rows and the recordset is ... > I felt like I was losing my mind. ...
    (microsoft.public.dotnet.framework.aspnet)