PDA

View Full Version : using System.Data


mgbloomfield
04-16-2008, 05:16 PM
In NinjaScript, am I able to use System.Data?

using System;
using System.Data;

It didn't appear in the list of references.

NinjaTrader_Ray
04-16-2008, 07:25 PM
You can use any valid .NET namespace. In the editor, just type "System." excluding quotations to confirm.

mgbloomfield
04-16-2008, 11:34 PM
Hmmm... System.Data is the only one that doesn't confirm.

In Visual Studio, I can confirm the following:

using System;
using System.CodeDom;
using System.Collections;
using System.ComponentModel;
using System.Configuration;
using System.Data;
using System.Deployment;
using System.Diagnostics;
using System.Drawing;
using System.Globalization;
using System.IO;
using System.Media;
using System.Net;
using System.Reflection;
using System.Resources;
using System.Runtime;
using System.Security;
using System.Text;
using System.Threading;
using System.Timers;
using System.Web;
using System.Windows;
using System.Xml;

In NinjaTrader, I can confirm the following. Notice that System.Data is not on the list.

using System;
using System.CodeDom;
using System.Collections;
using System.ComponentModel;
using System.Configuration;
using System.Deployment;
using System.Diagnostics;
using System.Drawing;
using System.Globalization;
using System.IO;
using System.Media;
using System.Net;
using System.Reflection;
using System.Resources;
using System.Runtime;
using System.Security;
using System.Text;
using System.Threading;
using System.Timers;
using System.Web;
using System.Windows;
using System.Xml;

Any ideas why?

NinjaTrader_Dierk
04-16-2008, 11:49 PM
Not sure I follow.

Just add
using System.Data:
... to your NinjaScript code and you should be good.

Note: We do not provide support for using VS for editing NS files. Please use the NT built-in editor.

mgbloomfield
04-17-2008, 09:02 AM
using System.Data;
using System.Data.SqlClient;

SqlCommand myCommand = new SqlCommand();

When I compile, it raises an compile error, "The type of namespace name 'Data' does not exist in the namespace 'System' (are you missing an assembly reference?)"

NinjaTrader_Dierk
04-17-2008, 09:07 AM
You likely will need to add references by right click->References. Please consult the Microsoft documentation for details on which assemblies etc.

Unfortunately this is beyond what we can provide support for.

mgbloomfield
04-17-2008, 11:33 AM
To fix the problem, I modified the Config.xml file.

BEFORE

<NinjaTrader>
<Options>
<InstalledAt>
<dateTime>2008-04-15T10:42:36.4000784-07:00</dateTime>
</InstalledAt>
<References>
<ArrayOfString xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<string>System.dll</string>
<string>System.Drawing.dll</string>
<string>System.XML.dll</string>
<string>System.Windows.Forms.dll</string>
<string>C:\Program Files\NinjaTrader 6.5\bin\NinjaTrader.Core.dll</string>
<string>C:\Program Files\NinjaTrader 6.5\bin\WilsonORMapper.dll</string>
<string>C:\Documents and Settings\test\My Documents\NinjaTrader 6.5\bin\Custom\NinjaTrader.Vendor.dll</string>
</ArrayOfString>
</References>

AFTER (added System.Data.dll to the list of References)

<NinjaTrader>
<Options>
<InstalledAt>
<dateTime>2008-04-15T10:42:36.4000784-07:00</dateTime>
</InstalledAt>
<References>
<ArrayOfString xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<string>System.dll</string>
<string>System.Data.dll</string>
<string>System.Drawing.dll</string>
<string>System.XML.dll</string>
<string>System.Windows.Forms.dll</string>
<string>C:\Program Files\NinjaTrader 6.5\bin\NinjaTrader.Core.dll</string>
<string>C:\Program Files\NinjaTrader 6.5\bin\WilsonORMapper.dll</string>
<string>C:\Documents and Settings\test\My Documents\NinjaTrader 6.5\bin\Custom\NinjaTrader.Vendor.dll</string>
</ArrayOfString>
</References>

Rebooted NinjaTrader and viola!

NinjaTrader_Dierk
04-17-2008, 11:38 AM
a) sorry, in your post System.Data.dll is included in the BEFORE image
b) you NEVER should edit the Config.xml, since this easily could screw up your installation but add any/delete reference by my post below (NinjaScript editor->Right click->References)

mgbloomfield
04-17-2008, 11:40 AM
It wasn't clear to me if add/remove References (NinjaScript editor->Right click->References) would apply to all NinjaScripts or apply only to the specific indicator.

I fixed my post.