# Using SQL with Topspeed ODBC

**URL:** <https://clarionhub.com/t/using-sql-with-topspeed-odbc/6061>\
**Category:** questions\
**Tags:** odbc, tps\
**Created:** [March 21, 2023, 2:06am UTC](https://clarionhub.com/t/using-sql-with-topspeed-odbc/6061 "2023-03-21T02:06:43Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![Amnon\_Meyers](https://clarionhub.com/user_avatar/clarionhub.com/amnon_meyers/32/3943_2.png) [@Amnon\_Meyers](https://clarionhub.com/u/Amnon_Meyers)\
**Post date:** [March 21, 2023, 2:06am UTC](https://clarionhub.com/t/using-sql-with-topspeed-odbc/6061/1 "2023-03-21T02:06:43Z")

</div>

Looking for beginner help using SQL with Topspeed ODBC.  
Trying a simple SQL Insert statement, but nothing happens.  
How to see error messages from the ODBC driver, etc.  
Thx,  
Amnon Meyers  
[meyersamnon@gmail.com](mailto:meyersamnon@gmail.com)

---

<div class="post-metadata">

**Author:** ![softwaretailor](https://clarionhub.com/user_avatar/clarionhub.com/softwaretailor/32/5553_2.png) [@softwaretailor](https://clarionhub.com/u/softwaretailor)\
**Post date:** [March 21, 2023, 4:05am UTC](https://clarionhub.com/t/using-sql-with-topspeed-odbc/6061/2 "2023-03-21T04:05:03Z")

</div>

Hi Amnon,  
I think I have the answer for you. I might be way off-base.  
Just to clarify, because ODBC works in both directions.  
One way is to write a Clarion program, using Clarion statements obviously, to access a SQL database. This is ODBC but does not use the TopSpeed ODBC driver.  
The second way is the inverse: you want to write SQL statements to access a TopSpeed file. This way uses the TopSpeed ODBC driver.  
It sounds like you want to use the second way, that is, use SQL statements to access a .tps file.  
Also, you may not know, there are two flavors of the TopSpeed ODBC driver. The first one is free and it can read a .tps file. That is, it is read-only.  
The other is not free. You need to pay for it. I believe you need to buy a 20-pack for $699 from [SoftVelocity.com](http://SoftVelocity.com). It allows you do a “simple SQL Insert statement” and of course whatever SQL you want.  
It’s been awhile, but I think the free version doesn’t provide an errorcode or an error message if you try to insert a record.  
Bob

---

<div class="post-metadata">

**Author:** ![vitesse](https://clarionhub.com/user_avatar/clarionhub.com/vitesse/32/837_2.png) [@vitesse](https://clarionhub.com/u/vitesse)\
**Post date:** [March 21, 2023, 4:44am UTC](https://clarionhub.com/t/using-sql-with-topspeed-odbc/6061/3 "2023-03-21T04:44:02Z")

</div>

Hi Amnon

have a look at the info on this thread and see if it helps

> [@Replace TopScan with ODBC](https://clarionhub.com/t/replace-topscan-with-odbc/693):
>
> Shown on ClarionLive Sept/16/2016 by Greg Bailey If you’re using TPS files and TopScan here is a way to get a much nicer database browser. Note: use of the ODBC driver is free for developers, but is a $249 for a 5-user license for end-users Steps: Download, Install and Run: [Icetips Alta LLC download file](http://www.icetips.com/downloadfile.php?FileID=262) written by @ArnorBld it adds some registry entries and helps you open the correct ODBC Data Source Administrator (the 32 bit one) Point to your ODBC driver for TopSpeed %cwroot%\bi…

cheers

Geoff R

---

<div class="post-metadata">

**Author:** ![Amnon\_Meyers](https://clarionhub.com/user_avatar/clarionhub.com/amnon_meyers/32/3943_2.png) [@Amnon\_Meyers](https://clarionhub.com/u/Amnon_Meyers)\
**Post date:** [March 21, 2023, 5:32am UTC](https://clarionhub.com/t/using-sql-with-topspeed-odbc/6061/4 "2023-03-21T05:32:40Z")

</div>

Thx, I’ll need to check on which one I have – hopefully part of a commercial package, since it’s from a SoftVelocity user.

---

<div class="post-metadata">

**Author:** ![Amnon\_Meyers](https://clarionhub.com/user_avatar/clarionhub.com/amnon_meyers/32/3943_2.png) [@Amnon\_Meyers](https://clarionhub.com/u/Amnon_Meyers)\
**Post date:** [March 21, 2023, 6:01am UTC](https://clarionhub.com/t/using-sql-with-topspeed-odbc/6061/5 "2023-03-21T06:01:50Z")

</div>

Thx to all,  
More generally, how would you insert a record in a TPS file from a C++ program. SQL or otherwise.  
Would would the command look like, and how would it be executed, if not via an SQL-like language.  
Amnon

---

<div class="post-metadata">

**Author:** ![Amnon\_Meyers](https://clarionhub.com/user_avatar/clarionhub.com/amnon_meyers/32/3943_2.png) [@Amnon\_Meyers](https://clarionhub.com/u/Amnon_Meyers)\
**Post date:** [March 21, 2023, 6:06am UTC](https://clarionhub.com/t/using-sql-with-topspeed-odbc/6061/6 "2023-03-21T06:06:55Z")

</div>

Thanks, but this sounds like a manual interface.  
I need a programmatic solution. My C++ program needs to update a TPS file automatically (that is, not by a person typing commands.)  
Amnon

---

<div class="post-metadata">

**Author:** ![Bruce](https://clarionhub.com/letter_avatar_proxy/v4/letter/b/ccd318/32.png) [@Bruce](https://clarionhub.com/u/Bruce)\
**Post date:** [March 21, 2023, 6:47am UTC](https://clarionhub.com/t/using-sql-with-topspeed-odbc/6061/7 "2023-03-21T06:47:12Z")

</div>

> [@Amnon\_Meyers](#):
>
> Looking for beginner help using SQL with Topspeed ODBC.

So, I’ve never used the ODBC driver against Topspeed, but my instinct is that you are reading into it something that doesn’t exist.

Given that TPS is not a SQL engine (ie, it has no way to parse SQL statements), and given that I’m not _aware_ of the ODBC driver including a SQL-parsing engine, I feel like your initial premise (that the TPS ODBC somehow “supports SQL”) seems “unlikely”.

I might be wrong, so others can feel free to chip in, but I’ve not though of the ODBC driver as a SQL interface up to now.

---

<div class="post-metadata">

**Author:** ![Bruce](https://clarionhub.com/letter_avatar_proxy/v4/letter/b/ccd318/32.png) [@Bruce](https://clarionhub.com/u/Bruce)\
**Post date:** [March 21, 2023, 6:48am UTC](https://clarionhub.com/t/using-sql-with-topspeed-odbc/6061/8 "2023-03-21T06:48:39Z")

</div>

> [@Amnon\_Meyers](#):
>
> More generally, how would you insert a record in a TPS file from a C++ program. SQL or otherwise.  
> Would would the command look like, and how would it be executed, if not via an SQL-like language.

As I understand it, the ODBC interface is a standard. So you would need to investigate calling ODBC from C++, and use whatever tools and languages exist in that environment to make ODBC API calls.

---

<div class="post-metadata">

**Author:** ![vitesse](https://clarionhub.com/user_avatar/clarionhub.com/vitesse/32/837_2.png) [@vitesse](https://clarionhub.com/u/vitesse)\
**Post date:** [March 21, 2023, 11:17am UTC](https://clarionhub.com/t/using-sql-with-topspeed-odbc/6061/9 "2023-03-21T11:17:06Z")

</div>

not sure if this will help but the tps ODBC supported SQL syntax can be found at

> **[Pocket Access - Mobile Software - Mobile Database - Windows CE Database -...](https://www.syware.com/products/odbc_driver_kit/drdbdr3.php)**
>
> Provider of Pocket Access, Mobile Software, Mobile Database, Windows CE Database, Windows CE Forms, and more.

note that I understand the tps ODBC driver is built using “Dr. DeeBee ODBC Driver Kit”.

Also perhaps this MS link re C++ use of ODBC will help.

> **[C / C++ ODBC app accessing a SQL database - ODBC Driver for SQL Server](https://learn.microsoft.com/en-us/sql/connect/odbc/cpp-code-example-app-connect-access-sql-db?view=sql-server-ver16)**
>
> This C / C++ sample application demonstrates how to use the ODBC APIs to connect to and access a SQL database.

---

<div class="post-metadata">

**Author:** ![JonW](https://clarionhub.com/user_avatar/clarionhub.com/jonw/32/1344_2.png) [@JonW](https://clarionhub.com/u/JonW)\
**Post date:** [March 21, 2023, 2:31pm UTC](https://clarionhub.com/t/using-sql-with-topspeed-odbc/6061/10 "2023-03-21T14:31:23Z")

</div>

A couple more things that may be useful for you…  
There is a Clarion UltimateSQL" class that you can find on github ([UltimateSQL/libsrc at master · ClarionLive/UltimateSQL · GitHub](https://github.com/ClarionLive/UltimateSQL/tree/master/libsrc)). That’s basically a comprehensive clarion way to wrap around the low level ODBC calls that are similar to what is being done in the sample code that vitesse pointed you to. May give you a conceptual understanding of how to access data via ODBC.  
Secondly, in Clarion, in addition to using Clarion Adds and Puts to insert an update records, we can also to that using direct ODBC calls, e.g. myfile{PROP:SQL} = ‘insert into myfile values(’ & myf:id & ‘,\<39\>’ & some\_string & ‘\<39\>)’

Both those are possible because clarion, specifically the ODBC driver, translates in adds & puts and regular SQL into calls to SQLODBC commands like SQLColAtrtibute and SQLExecDirect etc. that then get passed to whatever specific ODBC back end you are trying to target, in this case the TPS ODBC driver.

You _may_ find it easier to write a Clarion DLL that actually talks to the data files (either using ODBC or native TPS access) and call those access functions in the DLL from C/C++. I only used the TPS ODBC driver a little, a long time ago, and my recollection is that the types of SQL statements that it would accept were very limited, they were designed to handle things similar to Clarion Adds/puts/deletes and not much more.

---

<div class="post-metadata">

**Author:** ![Amnon\_Meyers](https://clarionhub.com/user_avatar/clarionhub.com/amnon_meyers/32/3943_2.png) [@Amnon\_Meyers](https://clarionhub.com/u/Amnon_Meyers)\
**Post date:** [March 21, 2023, 2:32pm UTC](https://clarionhub.com/t/using-sql-with-topspeed-odbc/6061/11 "2023-03-21T14:32:59Z")

</div>

Thx,  
I can update eg MySQL databases with SQL commands via ODBC.  
What I can’t do right now is get the same to work for a Topspeed database file.  
With the same commands and methods I’ve used before in a C++ program.

Presumably Clarion has precedents for doing this.

And I can’t even figure out how to view any error messages, maybe someone can help with that?

Best regards,  
Amnon

---

<div class="post-metadata">

**Author:** ![Amnon\_Meyers](https://clarionhub.com/user_avatar/clarionhub.com/amnon_meyers/32/3943_2.png) [@Amnon\_Meyers](https://clarionhub.com/u/Amnon_Meyers)\
**Post date:** [March 21, 2023, 2:40pm UTC](https://clarionhub.com/t/using-sql-with-topspeed-odbc/6061/12 "2023-03-21T14:40:31Z")

</div>

Thanks for this,  
I’ve seen the grammar and I have working code for example for a MySQL database.

The same type of code is not working with a TPS file.

Is there a way to view the error messages produced by Topspeed ODBC?

Best regards,  
Amnon

---

<div class="post-metadata">

**Author:** ![Amnon\_Meyers](https://clarionhub.com/user_avatar/clarionhub.com/amnon_meyers/32/3943_2.png) [@Amnon\_Meyers](https://clarionhub.com/u/Amnon_Meyers)\
**Post date:** [March 21, 2023, 3:17pm UTC](https://clarionhub.com/t/using-sql-with-topspeed-odbc/6061/13 "2023-03-21T15:17:04Z")

</div>

Thanks for this,  
My needs are that simple, merely to add records to an existing TPS database file.  
But SQL commands that work with other databases aren’t working so far with Topspeed ODBC.  
(Is there a way to see the error messages?)  
The idea of a Clarion DLL is something I’ll try to get “my Clarion guy” to try!  
Amnon

---

<div class="post-metadata">

**Author:** ![JonW](https://clarionhub.com/user_avatar/clarionhub.com/jonw/32/1344_2.png) [@JonW](https://clarionhub.com/u/JonW)\
**Post date:** [March 21, 2023, 4:05pm UTC](https://clarionhub.com/t/using-sql-with-topspeed-odbc/6061/14 "2023-03-21T16:05:05Z")

</div>

If you do go down the Clarion DLL route, this might help:

[https://www.icetips.com/showarticle.php?articleid=355](https://www.icetips.com/showarticle.php?articleid=355)

Jim Kane was a very clever programmer, who is unfortunately no longer around the newsgroups.

---

<div class="post-metadata">

**Author:** ![Rick\_UpperPark](https://clarionhub.com/user_avatar/clarionhub.com/rick_upperpark/32/346_2.png) [@Rick\_UpperPark](https://clarionhub.com/u/Rick_UpperPark)\
**Post date:** [March 21, 2023, 8:08pm UTC](https://clarionhub.com/t/using-sql-with-topspeed-odbc/6061/15 "2023-03-21T20:08:27Z")

</div>

Amnon, I’m not sure what problems you are running into, but you should be able to insert rows into a TPS table via the ODBC driver.  
Here is view of a System DSN I have setup for a folder containing TPS files.

 ![image](https://clarionhub-uploads.s3.eu-north-1.amazonaws.com/original/2X/6/6f12fa154bf2bea61fd59756e7705f0edcff00b1.png)

In MS Access I added the files from that folder as external linked data to the Access database.  
Then I can use a query like below to insert a row in one of the tables. This definitely works. I just tested it.

 ![image](https://clarionhub-uploads.s3.eu-north-1.amazonaws.com/original/2X/0/06498950b5b68844dcc031b337df0a5893adb876.png)

Clearly this is using MS Access, not whatever development environment you are using. But you can definitely insert a row using a SQL command.

---

<div class="post-metadata">

**Author:** ![jslarve](https://clarionhub.com/letter_avatar_proxy/v4/letter/j/e480ec/32.png) [@jslarve](https://clarionhub.com/u/jslarve)\
**Post date:** [March 21, 2023, 8:25pm UTC](https://clarionhub.com/t/using-sql-with-topspeed-odbc/6061/16 "2023-03-21T20:25:21Z")

</div>

It could be possible that certain columns need a value to satisfy one or more keys. And some of them could need to be unique.

---

<div class="post-metadata">

**Author:** ![softwaretailor](https://clarionhub.com/user_avatar/clarionhub.com/softwaretailor/32/5553_2.png) [@softwaretailor](https://clarionhub.com/u/softwaretailor)\
**Post date:** [March 21, 2023, 8:55pm UTC](https://clarionhub.com/t/using-sql-with-topspeed-odbc/6061/17 "2023-03-21T20:55:29Z")

</div>

Hi Amnon,  
I assume your C++ program is using a SQL database. This is good.  
You can have a Clarion developer write a little Clarion program for you to copy rows from a SQL table to the tps file. No ODBC is involved.  
The Clarion programmer needs to know the columns of the table and the tps file, and anything special like dates or time columns.  
So, here are the steps:

1. Your C++ program inserts one or more rows into a SQL table.
2. Your C++ program runs the Clarion program, which returns a return code.
3. The Clarion program copies the rows from SQL table to the tps file.
4. Your C++ program checks whether the Clarion program returned an error code.
5. If no error is returned, your C++ program deletes the rows from the SQL table.  
This is what ODBC would do, but it isn’t “open”. The Clarion program is specific.  
If you don’t have a Clarion programmer associate, I can write it for you in a few minutes.  
Bob

---

<div class="post-metadata">

**Author:** ![Amnon\_Meyers](https://clarionhub.com/user_avatar/clarionhub.com/amnon_meyers/32/3943_2.png) [@Amnon\_Meyers](https://clarionhub.com/u/Amnon_Meyers)\
**Post date:** [March 21, 2023, 11:43pm UTC](https://clarionhub.com/t/using-sql-with-topspeed-odbc/6061/18 "2023-03-21T23:43:04Z")

</div>

Thanks, Bob,  
I’m looking for something even simpler.  
Just need to automatically populate a TPS database directly from a C++ function, with or without SQL syntax (that is, whatever works).  
Eg, a hardwired insert statement that adds a row to the TPS database.  
(I’ve been trying this, and it hasn’t worked.)

Someone has responded that I may need to be filling required fields, and that’s why things are not populating.  
(I’ll check that out, else get back to you!)  
With appreciation,  
Amnon

---

<div class="post-metadata">

**Author:** ![FedericoNavarro](https://clarionhub.com/letter_avatar_proxy/v4/letter/f/2acd7d/32.png) [@FedericoNavarro](https://clarionhub.com/u/FedericoNavarro)\
**Post date:** [March 22, 2023, 12:44am UTC](https://clarionhub.com/t/using-sql-with-topspeed-odbc/6061/19 "2023-03-22T00:44:09Z")

</div>

> [@Amnon\_Meyers](#):
>
> How to see error messages from the ODBC driver, etc.

Hi Amnon  
Have you tried turning on ODBC trace and looking at SQL.LOG to see if there is some information there? (old screen capture here [5.10.1&nbsp;Enabling ODBC Tracing on Windows](https://docs.oracle.com/cd/E17952_01/connector-odbc-en/connector-odbc-configuration-trace-windows.html))

Also note your C++ code should be 32bits as the ODBC Driver is.

Federico

---

<div class="post-metadata">

**Author:** ![Amnon\_Meyers](https://clarionhub.com/user_avatar/clarionhub.com/amnon_meyers/32/3943_2.png) [@Amnon\_Meyers](https://clarionhub.com/u/Amnon_Meyers)\
**Post date:** [March 22, 2023, 1:05am UTC](https://clarionhub.com/t/using-sql-with-topspeed-odbc/6061/20 "2023-03-22T01:05:59Z")

</div>

Hi Federico,  
Thanks, I will try that!  
I know I’m dealing with 32 bit everywhere (including my “C++ program”, actually called VisualText).  
Amnon

[Next page](https://clarionhub.com/t/using-sql-with-topspeed-odbc/6061.md?page=2)
