PlanetSquires Forums

Please login or register.

Login with username, password and session length
Advanced search  

Author Topic: Request for Access *.mb files  (Read 1493 times)

José Roca

  • FireFly3 Registered User
  • Master FireFly Member
  • *
  • Posts: 2785
    • José Roca Software
Request for Access *.mb files
« on: August 07, 2016, 03:19:15 AM »

I would like to write a class to wrap ODBC, but I only can test it in 32 bit because I don't have versions of biblio.mdb and northwind.mdb in 64 bit. Anybody has Access 32 and 64 bit *.mdb files to test?
« Last Edit: August 07, 2016, 02:00:05 PM by José Roca »
Logged

José Roca

  • FireFly3 Registered User
  • Master FireFly Member
  • *
  • Posts: 2785
    • José Roca Software
Re: Request for Access *.mb files
« Reply #1 on: August 07, 2016, 05:31:02 AM »

An small test:

Code: [Select]
'#define unicode
'#define _CODBC_DEBUG_ 1
#include once "Afx/COdbc/COdbc.inc"
USING Afx
' // Connect with the database
DIM wszConStr AS WSTRING * 260 = "DRIVER={Microsoft Access Driver (*.mdb)};DBQ=biblio.mdb"
DIM pDbc AS CODBC = wszConStr

' // Allocate an statement object
DIM pStmt AS COdbcStmt PTR = NEW COdbcStmt(@pDbc)
IF pStmt THEN
   ' // Generate a result set
   pStmt->ExecDirect ("SELECT TOP 20 * FROM Authors ORDER BY Author")
   ' // Parse the result set
   DIM cwsOutput AS CWSTR
   DO
      ' // Fetch the record
      IF pStmt->Fetch = FALSE THEN EXIT DO
      ' // Get the values of the columns and display them
      cwsOutput = ""
      cwsOutput += pStmt->GetData(1) & " "
      cwsOutput += pStmt->GetData(2) & " "
      cwsOutput += pStmt->GetData(3)
      PRINT cwsOutput
   LOOP
   Delete pStmt
END IF

PRINT
PRINT "Press any key..."
SLEEP
« Last Edit: August 07, 2016, 11:11:55 PM by José Roca »
Logged

Knuth Konrad

  • FireFly3 Registered User
  • Junior FireFly Member
  • *
  • Posts: 64
Re: Request for Access *.mb files
« Reply #2 on: October 07, 2016, 10:29:08 AM »

I would like to write a class to wrap ODBC, but I only can test it in 32 bit because I don't have versions of biblio.mdb and northwind.mdb in 64 bit. Anybody has Access 32 and 64 bit *.mdb files to test?

A bit late, but nontheless: I'm pretty sure there isn't a difference of a *.mdb file created with a 32 or 64 bit version of Access.

There is however a new Access file format: *.accdb. Never used that one, though.

BTW, MDB Viewer is a versatile free tool for dealing with Access files. And contrary to its name ("Viewer"), it let's you create MDB files also.
Logged

David Warner

  • FireFly3 Registered User
  • Junior FireFly Member
  • *
  • Posts: 110
Re: Request for Access *.mb files
« Reply #3 on: February 10, 2017, 10:02:09 AM »

Hi José,

I'm just taking a look at your ODBC class and my first impression is... Wow, that's amazing!
Thank you.

Cheers,

David
Logged

Paul Squires

  • Administrator
  • Master FireFly Member
  • *****
  • Posts: 8104
  • Windows 10
    • PlanetSquires Software
Re: Request for Access *.mb files
« Reply #4 on: February 10, 2017, 12:13:47 PM »

Hi José,

I'm just taking a look at your ODBC class and my first impression is... Wow, that's amazing!
Thank you.

Cheers,

David

I agree 100%. The work that José has done with the FB classes is incredible. Only last weekend I was having trouble with some file input/output so I switched to using José's CTextStream class and it worked perfectly (and it is syntactically more pleasing to deal with).
Logged
Paul Squires
PlanetSquires Software
FireFly Visual Designer, WinFBE Editor

David Warner

  • FireFly3 Registered User
  • Junior FireFly Member
  • *
  • Posts: 110
Re: Request for Access *.mb files
« Reply #5 on: February 10, 2017, 12:33:30 PM »

Jose’s CWindow framework truly is an amazing coding resource containing lots of interesting and useful items. There is a great deal of information to take in and I think we are fortunate indeed to have received such a generously given gift.
Logged

José Roca

  • FireFly3 Registered User
  • Master FireFly Member
  • *
  • Posts: 2785
    • José Roca Software
Re: Request for Access *.mb files
« Reply #6 on: February 10, 2017, 12:51:42 PM »

Thanks very much.

@Paul,

If you're using CTextStream, I have modified two of the methods: Read and ReadLine.

Code: [Select]
' ========================================================================================
' Reads a specified number of characters from a TextStream file and returns the resulting string.
' After a file is initially opened and before anything is written, Line is equal to 1.
' ========================================================================================
PRIVATE FUNCTION CTextStream.Read (BYVAL numChars AS LONG) AS CWSTR
   DIM bstrText AS AFX_BSTR
   IF m_pTxtStm THEN SetResult(m_pTxtStm->Read(numChars, @bstrText))
   DIM cwsText AS CWSTR = *bstrText
   SysFreeString bstrText
   RETURN cwsText
END FUNCTION
' ========================================================================================

' ========================================================================================
' Reads an entire line (up to, but not including, the newline character) from a TextStream
' file and returns the resulting string.
' ========================================================================================
PRIVATE FUNCTION CTextStream.ReadLine () AS CWSTR
   DIM bstrText AS AFX_BSTR
   IF m_pTxtStm THEN SetResult(m_pTxtStm->ReadLine(@bstrText))
   DIM cwsText AS CWSTR = *bstrText
   SysFreeString bstrText
   RETURN cwsText
END FUNCTION
' ========================================================================================

Previously the code used was:

Code: [Select]
DIM cwsText AS CWSTR = SysallocString(*bstrText)

Instead of

Code: [Select]
DIM cwsText AS CWSTR = *bstrText
[(code]

Because the original version returned a CBSTR instead of a CWSTR.
« Last Edit: February 10, 2017, 06:24:54 PM by José Roca »
Logged

José Roca

  • FireFly3 Registered User
  • Master FireFly Member
  • *
  • Posts: 2785
    • José Roca Software
Re: Request for Access *.mb files
« Reply #7 on: February 10, 2017, 01:10:54 PM »

Unfortunately, the lack of native support for BSTRrings forces to have to make copies of the data.

Paul Squires

  • Administrator
  • Master FireFly Member
  • *****
  • Posts: 8104
  • Windows 10
    • PlanetSquires Software
Re: Request for Access *.mb files
« Reply #8 on: February 10, 2017, 04:26:10 PM »

Thanks José, I only used the class to write/output files. I didn't need to read them at the time. Thanks for letting me know that you've change the code.
Logged
Paul Squires
PlanetSquires Software
FireFly Visual Designer, WinFBE Editor