I am attempting to connect to an Intersystems Caché database using C# and I want to fetch all available namespaces. My current code snippet looks as follows:
namespace SampleApp
{
internal class Program
{
static void Main(string[] args)
{
var connectionString = "Server=XXXXX;User=system;Password=sys;";
var connection = new InterSystems.Data.CacheClient.CacheConnection(connectionString);
connection.Open();
var sqlCommand = connection.CreateCommand();
sqlCommand.CommandText = "SELECT * FROM %SYS.Namespace_List()";
var reader = sqlCommand.ExecuteReader();
while (reader.Read())
{
// Process results
}
}
}
}
Unfortunately, this leads to an error:
InterSystems.Data.CacheClient.CacheException: '[SQLCODE: <-99>:<Privilege violation>] [Location: <Prepare>] [%msg: <User system is not privileged for the operation>]'
It appears that I lack the necessary permissions. However, when I specify a namespace in my connection string, the query executes successfully. Can anyone suggest how I might retrieve a list of user-available namespaces using SQL?