Error: "The owner SID on a per-user subscription does not exist." Say what?

375
3
Jump to solution
11-15-2021 11:47 AM
RogerAsbury
New Contributor II

Trying to do an SQL db query within an arcgis pro sdk project. I've successfully queried another db in this project, but this query is throwing the error in the subject line. I've confirmed the user/password has access to this db in Microsoft's SQL management tools. 

Example code that is throwing the error below:

QueryDef qDef = new QueryDef 

{

  Subfields = "[database].table1.IDfield",

  Tables = "[database].table1, [database].table2",

  WhereClause = "[database].table1.IDfield = [database].table2.recordid"

}

using (RowCursor rc = db.Evaluate(qDef, false)) {

 //Do some stuff

}

The error is thrown as soon as the Evaluate is attempted. The variable "db" is a valid Geodatabase connection that I've used before successfully.

After much googling, I haven't found much. One site said that the "[]" is a Microsoft centric thing and not valid SQL and to remove them. This generates another error, "The specified database (or data source) name is invalid." I can confirm that the database exists and that my user has access to it. 

Wondering if anyone can shed light on what might be going on here.

 

Tags (3)
0 Kudos
1 Solution

Accepted Solutions
AashisLamsal1
Esri Contributor

@RogerAsbury Is the database for the "db" connection different from the "database" that you are trying to access tables? The queryDef in Evaluate method "Represents a query involving one or more tables from the same geodatabase.

Here are some examples of using QueryDef.

View solution in original post

3 Replies
AashisLamsal1
Esri Contributor

@RogerAsbury Is the database for the "db" connection different from the "database" that you are trying to access tables? The queryDef in Evaluate method "Represents a query involving one or more tables from the same geodatabase.

Here are some examples of using QueryDef.

View solution in original post

RogerAsbury
New Contributor II

Ok, this is likely the answer then. Yeah, I am trying to query a different database. Was hoping since the credentials were the same I could reuse the connection. Thanks much!

0 Kudos
Wolf
by Esri Regular Contributor
Esri Regular Contributor

I can't tell from your post if you are trying to use a Microsoft SQL Server database variant, but if you do and you are trying to use a fully qualified name to access tables (or fields), you have to use this format: form database.schema.object_name.

Looking like this:

select * from [ArcObjects].[dbo].[Image];

or 

select * from ArcObjects.dbo.Image;

Consequently this syntax from your post will not work since it's missing the database schema: [database].table1