Channel: ClearScript
Viewing all articles
Browse latest Browse all 2297

Commented Issue: Using ADODB recordsets [69]

How to properly add ADODB.Recordset? Is it possible?
static void Main(string[] args)
ADODB.Recordset _recordset = new ADODB.Recordset();
_recordset.Fields.Append("Id", ADODB.DataTypeEnum.adInteger);
_recordset.Fields.Append("Name", ADODB.DataTypeEnum.adVarChar, 20);
, System.Reflection.Missing.Value
, ADODB.CursorTypeEnum.adOpenStatic
, ADODB.LockTypeEnum.adLockOptimistic, 0);
_recordset.AddNew(Type.Missing, Type.Missing);
_recordset.Fields["Name"].Value = "Test";
Microsoft.ClearScript.Windows.VBScriptEngine engine = new Microsoft.ClearScript.Windows.VBScriptEngine();
engine.AllowReflection = true;
engine.AddHostObject("RS", _recordset);
engine.Execute("RS.MoveFirst"); // Ok
engine.Execute("RS.Fields(\"Name\").Value = \"Ok\""); // Error
Comments: Clarification: Once this bug is fixed (in the next ClearScript point release), the correct VBScript syntax for setting the field will be: ``` VBScript RS.Fields.Item("Name").Value = "Ok" ``` Note that that the `Item` property is a COM interop artifact. VBScript and JScript can also interface _directly_ with COM objects (without ClearScript's involvement), in which case the above syntax might work.

Viewing all articles
Browse latest Browse all 2297