**我的Oledb源代码是 -
添加第二个参数时,它会先覆盖。怎么解决?**
IDTSComponentMetaData100 Source = PopulateEtlDataSourceDetailDFT.ComponentMetaDataCollection.New();
Source.ComponentClassID = "DTSAdapter.OleDbSource";
CManagedComponentWrapper srcDesignTime = Source.Instantiate();
srcDesignTime.ProvideComponentProperties();
Source.Name = "OLEDB Source";
//Assigning Connection manager
Source.RuntimeConnectionCollection[0].ConnectionManagerID = Config.ID;
Source.RuntimeConnectionCollection[0].ConnectionManager = DtsConvert.GetExtendedInterface(Config);
// Set the custom properties of the source.
srcDesignTime.SetComponentProperty("AccessMode", 2);
Guid variableGuid = new Guid(ETLSourceRunId.ID);
String ParamProperty = @"""@OrganizationName"",{" + variableGuid.ToString().ToUpper() + @"};";
srcDesignTime.SetComponentProperty("ParameterMapping", ParamProperty);
Guid variableGuid1 = new Guid(Parent_ETLSourceRunId.ID);
String ParamProperty1 = @"""@SourceRunID"",{" + variableGuid.ToString().ToUpper() + @"};";
srcDesignTime.SetComponentProperty("ParameterMapping", ParamProperty1);
srcDesignTime.SetComponentProperty("SqlCommand","EXEC [dbo].[USP_GetCustomerEtlSourceDetailRecordSet] @OrganizationName=?,@SourceRunID=?");
srcDesignTime.AcquireConnections(null);
srcDesignTime.ReinitializeMetaData();
srcDesignTime.ReleaseConnections();
1。如何向oledb源添加多个参数?和
2.如何将项目参数添加到oledb源?
答案 0 :(得分:0)
我不是c#的专业人士,但是:
Guid variableGuid = new Guid(ETLSourceRunId.ID);
String ParamProperty = @"""@OrganizationName"",{" + variableGuid.ToString().ToUpper() + @"};";
srcDesignTime.SetComponentProperty("ParameterMapping", ParamProperty);
Guid variableGuid1 = new Guid(Parent_ETLSourceRunId.ID);
String ParamProperty1 = @"""@SourceRunID"",{" + variableGuid.ToString().ToUpper() + @"};";
srcDesignTime.SetComponentProperty("ParameterMapping", ParamProperty1);
最后一行第二名:
String ParamProperty1 = @"""@SourceRunID"",{" + variableGuid.ToString().ToUpper() + @"};";
不应该是 variableGuid1.ToString()。Upper()而不是 variableGuid.ToString()。Upper()因为你好了将值指定为:
Guid variableGuid1 = new Guid(Parent_ETLSourceRunId.ID);
答案 1 :(得分:0)
尝试使用变量中的SQL命令作为数据访问模式。创建一个变量作为字符串,并将其值设置为您的SqlCommand。如果SqlCommand需要多个参数,则再次创建变量来存储这些值,并在SqlCommand变量值中使用这些变量。
您可以按照this条开头。
步骤
1)为SqlCommand创建变量
strVarSqlCommand = "EXEC [dbo].[USP_GetCustomerEtlSourceDetailRecordSet] @OrganizationName=strVarOrgName ,@SourceRunID=strVarSrcRunId"
2)创建要在Sqlcommand变量
中引用的变量strVarOrgName = "XXX"
strVarSrcRunId="YYY"
根据您的要求,您可以将这些变量的值设置为硬编码或动态。
3)在ole db source中使用strVarSqlCommand
变量,其中数据访问模式是带变量的命令