Xojo Conferences
XDCMay2019MiamiUSA

Accessing an ODBC database programmatically (Windows) (Real Studio Plugins Mailinglist archive)

Back to the thread list
Previous thread: calling SetEntriesInAcl in a plugin crashes
Next thread: CodeWarrrior plugins & Intel Macs ?


macosx and unix paths   -   GOLD
  Accessing an ODBC database programmatically (Windows)   -   Malcolm Cowen
   Re: Accessing an ODBC database programmatically (Windows)   -   Jonathan Monroe
   Re: Accessing an ODBC database programmatically (Windows)   -   Malcolm Cowen
   Re: Accessing an ODBC database programmatically (Windows)   -   Jonathan Monroe

Accessing an ODBC database programmatically (Windows)
Date: 06.06.05 23:05 (Mon, 06 Jun 2005 23:05:17 +0100)
From: Malcolm Cowen

>I've just got RB 5.5, and need to connect programmatically to an Access
>DB, but I'm having trouble.
>
>If I connect via File/Add Data Source, then I can open the ODBC link and
>examine the tables ( proving it works ok).
>If I try to do it programatically, using the code dragged in from the
>reference screen, then instead of popping up a selection window ( as per
>documentation), it just fails.
>I've seen some old references to this ( 2004 and earlier ) in the support
>fora.
>Was this issue ever resolved?
>
>Code as dragged in from support window:
> Dim db as ODBCDatabase
> db=New ODBCDatabase
> db.DataSource=""
> If db.Connect then
> //proceed with database operations
> else
> MsgBox "The connection failed." <-------- fails here
> end if

Cheers
Malcolm Cowen

Malcolm Cowen, Software Developer, Cowen Software Ltd:
+44 (0) 161 225 4674 (office) +44 (0) 7973 950 597 (mobile)
www.cowensw.co.uk, www.cowensw.com


_______________________________________________
Unsubscribe or switch delivery mode:
<http://www.realsoftware.com/support/listmanager/>

Search the archives of this list here:
<http://support.realsoftware.com/listarchives/lists.html>

Re: Accessing an ODBC database programmatically (Windows)
Date: 07.06.05 19:47 (Tue, 7 Jun 2005 11:47:15 -0700)
From: Jonathan Monroe
On Jun 7, 2005, at 10:01 AM, Malcolm Cowen wrote:

>> I've just got RB 5.5, and need to connect programmatically to an
>> Access
>> DB, but I'm having trouble.

>> If I try to do it programatically, using the code dragged in from the
>> reference screen, then instead of popping up a selection window ( as
>> per
>> documentation), it just fails.

>> Code as dragged in from support window:
>> Dim db as ODBCDatabase
>> db=New ODBCDatabase
>> db.DataSource=""
>> If db.Connect then
>> //proceed with database operations
>> else
>> MsgBox "The connection failed." <-------- fails here
>> end if

This code works for me - I can connect to an Access database when
running an application under Windows with no problem.

If you add the following code to the "fails here" branch, what message
do you get?

If db.Error Then
MsgBox db.ErrorMessage
End If

Jonathan Monroe
Actual Technologies - ODBC for OS X
http://www.actualtechnologies.com
<email address removed>

_______________________________________________
Unsubscribe or switch delivery mode:
<http://www.realsoftware.com/support/listmanager/>

Search the archives of this list here:
<http://support.realsoftware.com/listarchives/lists.html>

Re: Accessing an ODBC database programmatically (Windows)
Date: 08.06.05 00:16 (Wed, 08 Jun 2005 00:16:21 +0100)
From: Malcolm Cowen

At 19:47 07/06/2005, you wrote:
>On Jun 7, 2005, at 10:01 AM, Malcolm Cowen wrote:
>
>>>I've just got RB 5.5, and need to connect programmatically to an Access
>>>DB, but I'm having trouble.
>
>>>If I try to do it programatically, using the code dragged in from the
>>>reference screen, then instead of popping up a selection window ( as per
>>>documentation), it just fails.
>
>>>Code as dragged in from support window:
>>> Dim db as ODBCDatabase
>>> db=New ODBCDatabase
>>> db.DataSource=""
>>> If db.Connect then
>>> //proceed with database operations
>>> else
>>> MsgBox "The connection failed." <-------- fails here
>>> end if
>
>This code works for me - I can connect to an Access database when running
>an application under Windows with no problem.
>
>If you add the following code to the "fails here" branch, what message do
>you get?
>
> If db.Error Then
> MsgBox db.ErrorMessage
> End If
>
>Jonathan Monroe
>Actual Technologies - ODBC for OS X
>http://www.actualtechnologies.com
><email address removed>

Thanks
Tried it, it produces the message "Could not establish connection"
not too helpful!

Any ideas?

Malcolm

Code listing:
Dim db2 as ODBCDatabase
db2=New ODBCDatabase
db2.DataSource=""
If db2.Connect then
//proceed with database operations
else
MsgBox "The connection failed."
If db2.Error Then
MsgBox db2.ErrorMessage
End If
end if



Malcolm Cowen, Software Developer, Cowen Software Ltd:
+44 (0) 161 225 4674 (office) +44 (0) 7973 950 597 (mobile)
www.cowensw.co.uk, www.cowensw.com


_______________________________________________
Unsubscribe or switch delivery mode:
<http://www.realsoftware.com/support/listmanager/>

Search the archives of this list here:
<http://support.realsoftware.com/listarchives/lists.html>

Re: Accessing an ODBC database programmatically (Windows)
Date: 08.06.05 18:42 (Wed, 8 Jun 2005 10:42:54 -0700)
From: Jonathan Monroe

On Jun 8, 2005, at 10:00 AM, Malcolm Cowen wrote:

> Tried it, it produces the message "Could not establish connection"
> not too helpful!

One thing you could try is to do a DSN-less connection, where you dully
specify the connection in the RB code instead of selecting the DSN in
the ODBC chooser. It might at least give you more information:

db.DataSource = "DRIVER={Microsoft Access Driver
(*.mdb)};DBQÀ\Northwind.mdb"

Jonathan Monroe
Actual Technologies - ODBC for OS X
http://www.actualtechnologies.com
<email address removed>

_______________________________________________
Unsubscribe or switch delivery mode:
<http://www.realsoftware.com/support/listmanager/>

Search the archives of this list here:
<http://support.realsoftware.com/listarchives/lists.html>