从脚本组件读取系统变量
从脚本组件读取系统变量的最佳方法是什么?
尝试如下:当用户变量
base.PreExecute();
IDTSVariables100 variables = null;
VariableDispenser.LockForRead("System::ContainerStartTime");
VariableDispenser.GetVariables(out variables);
auditTimeStamp = Convert.ToDateTime(variables[1].Value);
System.Windows.Forms.MessageBox.Show(auditTimeStamp.ToString());
variables.Unlock();
尝试读取系统变量时,工作正常,抛出以下错误:
脚本组件在用户代码中遇到异常: 项目名称:SC_0bfc7da1c6fe4b83bc124b87eb4178e5 HRESULT 异常:
Microsoft.SqlServer.Dts.Runtime.Wrapper.IDTSVariables100.get_Item(对象索引)处的 0xC0010009 在 ScriptMain.PreExecute() 请在 Microsoft.SqlServer.Dts.Pipeline.ScriptComponentHost.PreExecute()
提供任何线索。
谢谢
What is the best way to read system variables from Script Component.
Tried as below: Works fine when is User variable
base.PreExecute();
IDTSVariables100 variables = null;
VariableDispenser.LockForRead("System::ContainerStartTime");
VariableDispenser.GetVariables(out variables);
auditTimeStamp = Convert.ToDateTime(variables[1].Value);
System.Windows.Forms.MessageBox.Show(auditTimeStamp.ToString());
variables.Unlock();
when tried to read System variable throws following error:
Script Component has encountered an exception in user code:
Project name: SC_0bfc7da1c6fe4b83bc124b87eb4178e5
Exception from HRESULT: 0xC0010009
at Microsoft.SqlServer.Dts.Runtime.Wrapper.IDTSVariables100.get_Item(Object Index)
at ScriptMain.PreExecute()
at Microsoft.SqlServer.Dts.Pipeline.ScriptComponentHost.PreExecute()
any clues please.
Thanks
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
您已将索引从 更改
为
You have changed the index, from
to
好的,完成了,因为
这工作正常..不确定我以前做错了什么。
Ok got this done as
This works fine..not sure what i have done wrong previously.
您可以创建一个用户变量,该变量被计算为引用系统变量的表达式。像这样的东西
You could create a user variable that is evaluated as an expression that references the system variable. Something like this