Troubleshooting
Why PI ODBC fails with SQLSTATE 08004 before a query runs
Short answer
SQLSTATE 08004 is the ODBC wrapper; the driver's detailed exception names the real fault. A UriFormatException means the connection string is misparsed: build a driver DSN and set the DAS field to the machine running PI SQL DAS. TCP error 10061 on port 5462 means nothing is listening there: check the service state, the listening address and the firewall rule, then verify the locally installed PI OLE DB components.
On this page
- Read the driver's exception, not the SQLSTATE
- Rebuild the connection as a DSN
- Test each route outside your application
- Make the DAS host answer on its endpoint
- Verify the components on both machines
- Worked example: the 10061 refusal that came back in 0.997 s
- Choose the route before the project slips
- Questions asked
SQLSTATE 08004 on a PI ODBC connection is a wrapper, not a diagnosis: the driver's detailed exception names the real fault. In the reported case the same code covered two different failures — first a System.UriFormatException from a connection string the driver could not parse, then a refused connection to the PI SQL DAS query endpoint on port 5462 with TCP error code 10061. Fix them in that order: rebuild the connection as a driver DSN with the DAS field aimed at the machine running PI SQL DAS, then make that service listen and stay reachable with the firewall left enabled. When the OLE DB test returns data and the ODBC test keeps refusing, the broken hop is driver-to-DAS, and moving your client to OLE DB is the working fallback.
Read the driver's exception, not the SQLSTATE #
ODBC reports one class-08 code for a rejected connection and lets the driver explain why, so the SQLSTATE alone cannot tell you which stage failed. Read the complete diagnostic record — message, endpoint, duration — before you touch authentication settings. The four rows below cover what each reported result actually means.
| What the driver or tool reports | Stage that failed | First check |
|---|---|---|
System.UriFormatException: Invalid URI: The hostname could not be parsed |
No endpoint was ever formed; the connection string used fields the driver does not parse | Rebuild the connection as a DSN and set the DAS field |
System.ServiceModel.EndpointNotFoundException with TCP error code 10061 |
The endpoint was formed and the target machine refused it | DAS host identity, service state, listening port |
| The same error from the DSN test, the driver's test tool and your application | The fault sits outside your SQL and column bindings | Repair the service path before editing any query |
| The PI OLE DB test tool returns data | The OLE DB route works under that test's identity | Compare its provider, data source and identity with the ODBC route |
An endpoint refusal is neither a bad tag name nor a column-binding fault: no query has reached the server at that stage. The discipline of reading the driver's own message pays off across ODBC faults on a plant-floor PC — the fix for an ODBC SSL Security error 08001 on an edge PC starts from the driver's detail for the same reason.
Rebuild the connection as a DSN #
The first attempt borrowed the SQL Server connection layout and pointed it at PI:
Driver={PI ODBC Driver};Server=[10.64.19.15];Provider Type=PIOLEDBINT;Initial Catalog=piarchive;Provider String={Data Source=PI Servers;Integrated Security=SSPI;};
None of Server=, Provider Type=PIOLEDBINT or Initial Catalog=piarchive tells the PI ODBC driver where its service endpoint lives, and the documented guidance for this exact error is that the data source is not properly specified. Stop hand-writing the string and build a DSN instead: the vendor's configuration guide for the PI SQL client ODBC driver says to open the ODBC Data Source Administrator on your machine, select the tab for the DSN type you need and click Add — and the dialog includes a connection test.
With the corrected fields, the driver formed net.tcp://10.XX.XX.15:5462/DataAccessServer/Query from the DAS value, which is how the DAS field — not Server= — selects the service host. The field set below is the diagnostic configuration from the reported failure, not a verified working string:
Driver={PI ODBC Driver};DAS=10.XX.XX.15;Trusted_Connection=Yes;DATA SOURCE TYPE=PIOLEDB;DATA SOURCE=PI Servers;DATA SOURCE OPTIONS={Integrated Security=SSPI;};
| Field | What it selects |
|---|---|
DAS |
The machine running PI SQL DAS, which the driver connects to |
DATA SOURCE TYPE=PIOLEDB |
The provider route served through that DAS host |
DATA SOURCE |
The provider's data source, named as the DAS host knows it |
Trusted_Connection=Yes |
Windows authentication for the driver connection |
PI ODBC never talks to the PI Data Archive directly: PI SQL DAS sits between the driver and the data and uses its locally installed providers. A Data Archive address in the DAS field therefore works only when that machine also runs the DAS service. The change from the first string to the second moved the failure from URI parsing to a named endpoint — evidence that the parse stage cleared and troubleshooting had advanced.
Test each route outside your application #
- Run the DSN's Test Connection in the ODBC Data Source Administrator first, so no application code is involved.
- Run PIODBCTester.exe from
C:\Program Files\PIPC\ODBC3\Tools\PI ODBC Testeron the application computer. The reported case reproduced the identical refusal here, which cleared the C++ code, the SQL and the column bindings. - Run PIOLEDBTester.exe from
C:\Program Files\PIPC\OLEDB\Tools64\PI OLEDB Tester\PIOLEDBTester.exeon the same computer. In the reported case this returned data, which put the provider route, the network path and the data side on the working side of the ledger.
When both ODBC-side tests fail identically while the OLE DB test succeeds, the isolated hop is the ODBC driver's connection to the DAS service — every other link in the chain has testimony.
Make the DAS host answer on its endpoint #
The refused attempt targeted net.tcp://10.XX.XX.15:5462/DataAccessServer/Query, and the driver's administrator guide documents this failure shape verbatim — an error record reading ERROR [08004] [PIODBC] [PI SQL DAS gSOAP Channel] No connection could be made because the target machine actively refused it. Work the checks in this order:
- Confirm the address inside the endpoint is the machine you intend as the DAS host — not just the PI Data Archive host, unless the DAS service runs there too.
- On that host, confirm the PI SQL DAS service is running and listening on the configured endpoint while a DSN test runs. In the reported installation the listener belonged to
pisqldas64.exeon port 5462. - Keep the firewall enabled and add a narrow rule for the client-to-DAS endpoint. Turning the firewall off changed nothing in the reported case, which moves the suspicion to host selection, service state and listening address — a disabled firewall is not a configuration to keep.
- Do not stop
pisqldas64.exeto free the port: that deletes the listener the driver needs. If another process owns the port, resolve the conflict through the service configuration.
A refusal at this stage is a service problem, not a data problem: tags, SQL syntax and column bindings become diagnosable only after the connection opens.
Verify the components on both machines #
A client driver alone does not complete the route. The DAS host needs local copies of the providers, and the application computer needs the driver:
- PI ODBC Driver — on the application computer; exposes the ODBC interface and connects to the DAS host.
- PI SQL DAS — on the machine the DAS field names; accepts the driver's service connection.
- PI OLE DB Classic — local to the DAS service; reaches the PI Data Archive.
- PI OLE DB Enterprise — local to the DAS service; reaches the PI AF Server.
The reported machine advertised its own gap: PI SQL Commander Lite listed no ODBC data sources until PI ODBC Driver 2015 version 3.1.5.403 was installed, and the 2016 R2 release of the driver ships with PI SQL Commander Lite included. Record the installed packages and versions on both computers before reinstalling anything — that inventory is what turns a support question into an answer.
Worked example: the 10061 refusal that came back in 0.997 s #
The inputs, each from the reported case:
- DAS field in the DSN: 10.XX.XX.15, the address as masked in the report.
- Endpoint the driver formed:
net.tcp://10.XX.XX.15:5462/DataAccessServer/Query, quoted from the exception text. - Failure class: TCP error code 10061 — the target machine actively refused it.
- Attempt duration: 0.997 s, from the driver's reported time span of
00:00:00.9970000. - Control test: PIOLEDBTester.exe on the same computer returned data.
The rule: a Windows socket connect ends in error 10061 when the remote host's IP stack answers the attempt with an active refusal. The packet path to that host works, and whatever answered said that nothing was listening on that port at that moment — or that a firewall on that host actively rejected the segment. A silently dropped or filtered path behaves differently: your client burns its connect timeout on repeated retransmissions and never gets an answer.
The arithmetic: 00:00:00.9970000 is 0.997 s, so the refusal returned in about one second — a single round trip plus the rejection itself, far below the many-second waits a connect timeout consumes when segments are dropped. An immediate refusal is an answer, not a silence.
The result: the host at the DAS address was alive and responding at test time, and nothing was accepting connections on the DAS query endpoint. Because the firewall test produced no change and the OLE DB test succeeded on the same computer, the network path and the PI data side both worked; the fault is isolated to the ODBC driver's hop to the DAS service.
The decision: a refused DAS endpoint paired with a succeeding OLE DB test means you repair the service hop — service state, listening address, scoped firewall rule, installed provider components — before judging SQL, credentials or the driver itself. If that hop cannot be made healthy in your environment, reroute the client to OLE DB. That threshold is what sent the reported project to its fallback.
Choose the route before the project slips #
The reported project rewrote its client against OLE DB using ATL and connected, after PIOLEDBTester.exe had already proved the provider route worked on that machine. That outcome is a legitimate alternative for that environment; it is not evidence that PI ODBC itself cannot work, and the driver route does work when its service hop is healthy. Decide the route early in a migration rather than after weeks of retries — the validation-first approach used when choosing a PI System to Oracle integration route with validation applies here too.
Route mismatches of this kind are not unique to PI: Lookout SQL transfers and the correct ODBC route describes the same pattern on a different platform — a client pointed down a data-access route its source does not serve.
Work the stages in order — exception, DSN, service, components — and the SQLSTATE stops being a dead end: the detailed exception names the stage that owns the fault, and the failing test names the fix.
Questions asked
What does SQLSTATE 08004 mean in the ODBC standard?
In the ODBC 3.x error table, class 08 covers connection exceptions and 08004 means the data source rejected the establishment of the connection. The reason is not in the code itself: the driver writes its own detail underneath, which is why one SQLSTATE covered a URI parsing fault and a refused service port in the reported case. Read the driver's message, then the standard code.
Do you need a PI user name and password to use PI ODBC?
No. The reported project had no PI credentials and used Windows authentication throughout: Trusted_Connection=Yes for the driver and Integrated Security with SSPI in the data source options, provided the DAS host trusts the client's domain account. A credential problem surfaces after the endpoint answers, not as a refused port, so do not change authentication settings while the connection cannot even reach the service.
Is the classic PI SQL DAS service the only server-side option?
No. Newer PI SQL Data Access Server releases add the RTQP Engine mode, and that setup kit includes its required server components, while the classic mode depends on locally installed PI OLE DB Classic for the Data Archive and PI OLE DB Enterprise for the AF Server. Match the DSN to the mode your deployment documents before judging the driver route.
Which version evidence should you collect before asking the vendor?
Record the PI ODBC driver package and build, which in the reported install was version 3.1.5.403 of PI ODBC Driver 2015, whether PI SQL Commander Lite appears on the machine, the paths of the test tools that ran, and the full exception text with the endpoint it named. A question built from those four items is answerable in one pass instead of many rounds.