Getting Data back using literals

Using (or providing) Microsoft.NET Classes

Getting Data back using literals

Postby neeraj on Sun Mar 15, 2015 1:21 am

I have a C# program snippet. What is the equivalent expression in Dyalog

using System;
using System.Data;
using System.Data.Sql;
.
.
public static void Main(string[] args)
{
// Obtain the DataTable of SQL Server instances.
using (DataTable SqlSources =
SqlDataSourceEnumerator.Instance.GetDataSources())
{
// Enumerate the set of SQL Servers and display details.
Console.WriteLine("Discover SQL Server Instances:");
foreach (DataRow source in SqlSources.Rows)
{
Console.WriteLine(" Server Name:{0}", source["ServerName"]);
Console.WriteLine(" Instance Name:{0}",
source["InstanceName"]);
Console.WriteLine(" Is Clustered:{0}",
source["IsClustered"]);
Console.WriteLine(" Version:{0}", source["Version"]);
}
}

// Wait to continue.
Console.WriteLine(Environment.NewLine);
}
}

EQUIVALENT APL
Z←AllSqlServerInstances;⎕USING;SqlSources;source
⍝ Returns all SQL Server Instances
⎕USING←,⊂'System'
⎕USING,←'System.Data,System.Data.dll' 'System.Data.Sql,System.Data.dll'
SqlSources←SqlDataSourceEnumerator.Instance.GetDataSources
:For source :In SqlSources.Rows
source.ItemArray ⍝ This works
source[0] ⍝ This works as well
source["ServerName"] ⍝ This does not work
:EndFor
⎕←Environment.NewLine
neeraj
 
Posts: 78
Joined: Wed Dec 02, 2009 12:10 am
Location: Ithaca, NY, USA

Re: Getting Data back using literals

Postby PGilbert on Sun Mar 15, 2015 11:49 am

Could you try the following for the line that does not work:

Code: Select all
source[⊂'ServerName']
User avatar
PGilbert
 
Posts: 361
Joined: Sun Dec 13, 2009 8:46 pm
Location: Montréal, Québec, Canada

Re: Getting Data back using literals

Postby neeraj on Sun Mar 15, 2015 6:15 pm

That worked. I am lovin it.
neeraj
 
Posts: 78
Joined: Wed Dec 02, 2009 12:10 am
Location: Ithaca, NY, USA


Return to Microsoft.NET

Who is online

Users browsing this forum: No registered users and 1 guest