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.