I am attempting to build a vbscript interface through clearscript that can execute ado queries.
I am testing the scalability of executing a large amount of tests, and am finding that I receive an error when I execute above an uncertain threshold number of threads asynchronously (for me, somewhere around 500) .
The error I am receiving is:
"The program issued a command but the command length is incorrect. (Exception from HRESULT: 0x80070018)".
Does anyone have any thoughts as to the root of this issue?
Thanks,
Rob
The code I am running looks like this:
```
public class SCB
{
private Connection GetConn()
{
Connection m_Conn = new ADODB.ConnectionClass();
m_Conn.Mode = ADODB.ConnectModeEnum.adModeRead;
m_Conn.CursorLocation = ADODB.CursorLocationEnum.adUseClient;
m_Conn.Open("Provider=sqloledb;server=localhost;Database=test;User ID=test;Password=test", "", "", -1);
return m_Conn;
}
[ScriptMember(ScriptMemberFlags.ExposeRuntimeType)]
public Recordset ExecuteQuery(string sQuery)
{
if (string.IsNullOrEmpty(sQuery))
{
throw new Exception("Empty query");
}
try
{
object nullObject;
var m_Conn = GetConn();
Recordset rs = m_Conn.Execute(sQuery, out nullObject, 1);
rs.ActiveConnection = null;
m_Conn.Close();
return rs;
}
catch (Exception e)
{
throw e;
}
}
}
static string code = @"
Function GetUniversalMessage
dim lRS, sMessage, sColour,sTimeout
set lRS = SCB.executeQuery(""SELECT TOP 1 * FROM TBLWORKS"")
End Function
getuniversalmessage()
";
static void Main(string[] args)
{
var tasks = new Task[1000];
for (var index = 0; index < 1000; index++)
{
tasks[index] = Task.Factory.StartNew(DoWork);
}
Task.WaitAll(tasks);
}
public static void DoWork()
{
VBScriptEngine _engine = new VBScriptEngine(WindowsScriptEngineFlags.EnableDebugging /*| WindowsScriptEngineFlags.EnableJITDebugging*/);
_engine.AllowReflection = true;
_engine.AddHostObject("SCB", new SCB());
_engine.ExecuteCommand(code);
}
```
Comments: Reactivating to track the addition of defensive code to avoid the exception.
I am testing the scalability of executing a large amount of tests, and am finding that I receive an error when I execute above an uncertain threshold number of threads asynchronously (for me, somewhere around 500) .
The error I am receiving is:
"The program issued a command but the command length is incorrect. (Exception from HRESULT: 0x80070018)".
Does anyone have any thoughts as to the root of this issue?
Thanks,
Rob
The code I am running looks like this:
```
public class SCB
{
private Connection GetConn()
{
Connection m_Conn = new ADODB.ConnectionClass();
m_Conn.Mode = ADODB.ConnectModeEnum.adModeRead;
m_Conn.CursorLocation = ADODB.CursorLocationEnum.adUseClient;
m_Conn.Open("Provider=sqloledb;server=localhost;Database=test;User ID=test;Password=test", "", "", -1);
return m_Conn;
}
[ScriptMember(ScriptMemberFlags.ExposeRuntimeType)]
public Recordset ExecuteQuery(string sQuery)
{
if (string.IsNullOrEmpty(sQuery))
{
throw new Exception("Empty query");
}
try
{
object nullObject;
var m_Conn = GetConn();
Recordset rs = m_Conn.Execute(sQuery, out nullObject, 1);
rs.ActiveConnection = null;
m_Conn.Close();
return rs;
}
catch (Exception e)
{
throw e;
}
}
}
static string code = @"
Function GetUniversalMessage
dim lRS, sMessage, sColour,sTimeout
set lRS = SCB.executeQuery(""SELECT TOP 1 * FROM TBLWORKS"")
End Function
getuniversalmessage()
";
static void Main(string[] args)
{
var tasks = new Task[1000];
for (var index = 0; index < 1000; index++)
{
tasks[index] = Task.Factory.StartNew(DoWork);
}
Task.WaitAll(tasks);
}
public static void DoWork()
{
VBScriptEngine _engine = new VBScriptEngine(WindowsScriptEngineFlags.EnableDebugging /*| WindowsScriptEngineFlags.EnableJITDebugging*/);
_engine.AllowReflection = true;
_engine.AddHostObject("SCB", new SCB());
_engine.ExecuteCommand(code);
}
```
Comments: Reactivating to track the addition of defensive code to avoid the exception.