2012-08-17 2 views
0

나는 다음과 같은 코드를 vb6에 가지고 있으며,이 코드를 C# (Visual Studio 2010)으로 변환하는 방법을 알지 못합니다.vb6에서 C#으로 변환. Crystal Reports - ParameterFields

VB6 -

crtPanelStudyAuditTrail.ParameterFields(0) = "GA_PANEL;" & Trim(txtPanelStudy) & ";True" 
    crtPanelStudyAuditTrail.ParameterFields(1) = "GA_PANEL_LEG;" & Trim(txtPanelLeg) & ";True" 

C#을 변환

crtrptPanelStudyAuditTrail.DataDefinition.ParameterFields["GA_PANEL"].PromptText = "GA_PANEL;" + txtPanelStudy.ToString().Trim() + ";True"; 
    crtrptPanelStudyAuditTrail.DataDefinition.ParameterFields["GA_PANEL_LEG"].PromptText = "GA_PANEL_LEG;" + txtPanelLeg.ToString().Trim() + ";True"; 

가 인쇄 얻을 때마다 시도 -, 나는 "실종 매개 변수 값 오류"

인쇄 부분이 올바른지를 얻을 수 있기 때문에 내가 formulafields 및 그 잘 인쇄 변환 오전 다른 코드가 있습니다.

매개 변수 필드 행을 변환하는 방법에 대한 제안 사항은 무엇입니까 ??

답변

1

현재 매개 변수 값을 설정하지 않고 프롬프트 텍스트를 설정하고 있습니다. 프로그래밍 방식으로 매개 변수 값을 설정하는 여러 가지 방법이 있습니다. 보고서, 데이터 소스 등을 바인딩하는 방법에 따라 달라집니다. 아래에는 2 가지 옵션이 나와 있지만 실제로는 설정에 따라 달라집니다.

// Assuming "GA_PANEL" is the name of your parameter this is the simplest way to set it but depends on how you are binding the report 
crtrptPanelStudyAuditTrail.SetParameterValue("GA_PANEL", "GA_PANEL;" + txtPanelStudy.ToString().Trim() + ";True"); 


// Second method gives more flexibility in the types of parameters such as date, discrete, multi, etc. 
// Create a parameter value 
var paramVal = new ParameterDiscreteValue(); 
paramVal.Value = "GA_PANEL;" + txtPanelStudy.ToString().Trim() + ";True"); 

// Clear the current and default values from your parameter 
crtrptPanelStudyAuditTrail.ParameterFields["GA_PANEL"].CurrentValues.Clear(); 
crtrptPanelStudyAuditTrail.ParameterFields["GA_PANEL"].DefaultValues.Clear(); 

// Add your values to the parameter value collection 
crtrptPanelStudyAuditTrail.ParameterFields["GA_PANEL"].CurrentValues.Add(paramVal); 
crtrptPanelStudyAuditTrail.ParameterFields["GA_PANEL"].HasCurrentValue = true; 

// Refresh your report 
+0

첫 번째 옵션을 시도하면이 오류가 발생합니다. "매개 변수 필드의 유형과 매개 변수 필드의 현재 값이 호환되지 않습니다." 고맙습니다. – user1551783

+0

("GA_PANEL", recStudy [ "GA_PANEL"] ...)과 같은 CRecordset을 참조해야합니까 – user1551783

0

내가 크리스탈에 대해 많은 VB6 아무것도 모르지만, C#에서 해당하는 코드는 다음과 같이 보일 것입니다 :

crtrptPanelStudyAuditTrail.ParameterFields [0] = @ "GA_PANEL을;" + txtPanelStudy.Trim() + @ "; True";
crtrptPanelStudyAuditTrail.ParameterFields [1] = @ "GA_PANEL_LEG;" + txtPanelLeg.Trim() + @ "; True";

txtPanelStudy 및 txtPanelLeg는 이미 문자열이므로이를 변환 할 필요가 없습니다.

+0

txtPanelStudy 및 txtPanelLeg는 문자열이 아니라 텍스트 상자입니다. VB6은 암시 적으로 Text 속성을 참조합니다. – MarkJ