Click here to Skip to main content
11,710,423 members (81,470 online)
Rate this: bad
Please Sign up or sign in to vote.
See more: C#4.0 Exception SSRS
Hi there

I encountered this exception

The required field Field is missing from the input structure.Microsoft.ReportingServices.Diagnostics.Utilities.MissingElementException: The required field Field is missing from the input structure.

when i try to Programmatically create Datadrivensubscription using C#

Any help is appreciated..

Microsoft.SqlServer.ReportingServices2005.ReportingService2005 rsSubscription = new Microsoft.SqlServer.ReportingServices2005.ReportingService2005();
                rsSubscription.Credentials = rs.GetCredential();              
                rsSubscription.Url = "";
                //the name of the report for which the DDS is to be created
                string report = " /Reports/Invoice/InvoiceTest";
                string description = "Programmatic Data Driven Subscription for Windows File Share";
                //set extension as Windows File Share
                Microsoft.SqlServer.ReportingServices2005.ExtensionSettings settings = new Microsoft.SqlServer.ReportingServices2005.ExtensionSettings();
                settings.Extension = "Report Server FileShare";
                //set extension parameters values
                //we need to set the values for the different names for files,
                //path where the files will be delivered, the rendering format
                //for the report, the user name and
                //password which has write access to shared folder
                Microsoft.SqlServer.ReportingServices2005.ParameterValueOrFieldReference[] extensionParams = new Microsoft.SqlServer.ReportingServices2005.ParameterValueOrFieldReference[5];
                //this parameter takes the name for the file created with report same as the//sales order id.
                Microsoft.SqlServer.ReportingServices2005.ParameterFieldReference fnm = new Microsoft.SqlServer.ReportingServices2005.ParameterFieldReference();
                string timeStamp = DateTime.Now.ToString();
                fnm.ParameterName = "FILENAME";
                fnm.FieldAlias = "RevRecPrepaidTransfer@" + timeStamp;
                extensionParams[0] = fnm;
                //this path should follow UNC standard
                Microsoft.SqlServer.ReportingServices2005.ParameterValue Path = new Microsoft.SqlServer.ReportingServices2005.ParameterValue();
                Path.Name = "PATH";
                Path.Value = @"\\\Report_files";
                extensionParams[1] = Path;
                Microsoft.SqlServer.ReportingServices2005.ParameterValue renderFormat = new Microsoft.SqlServer.ReportingServices2005.ParameterValue();
                renderFormat.Name = "RENDER_FORMAT";
                renderFormat.Value = "HTML4.0";       
                extensionParams[2] = renderFormat;
                Microsoft.SqlServer.ReportingServices2005.ParameterValue uname = new Microsoft.SqlServer.ReportingServices2005.ParameterValue();
                uname.Name = "USERNAME";
                uname.Value = "Username";
                extensionParams[3] = uname;
                Microsoft.SqlServer.ReportingServices2005.ParameterValue password = new Microsoft.SqlServer.ReportingServices2005.ParameterValue();
                password.Name = "PASSWORD";
                //password.Value = "<password>"; 
                password.Value = "password@123";
                extensionParams[4] = password;
                //this step will assign all the parameter values
                settings.ParameterValues = extensionParams;
                //create data source
                Microsoft.SqlServer.ReportingServices2005.DataSource delivery = new Microsoft.SqlServer.ReportingServices2005.DataSource();
                delivery.Name = "";
                Microsoft.SqlServer.ReportingServices2005.DataSourceDefinition dataSourceDef = new
                dataSourceDef.ConnectString = @"data source=;initial catalog=DbTest;user id=User;password=User;";   
                dataSourceDef.CredentialRetrieval = Microsoft.SqlServer.ReportingServices2005.CredentialRetrievalEnum.Store;
                dataSourceDef.Enabled = true;
                dataSourceDef.EnabledSpecified = true;
                dataSourceDef.Extension = "SQL";
                dataSourceDef.ImpersonateUserSpecified = false;               
                dataSourceDef.UserName = "User";
                dataSourceDef.Password = "User";
                delivery.Item = dataSourceDef;
                Microsoft.SqlServer.ReportingServices2005.Field[] fieldlist = new Microsoft.SqlServer.ReportingServices2005.Field[1];
                fieldlist[0] = new Microsoft.SqlServer.ReportingServices2005.Field();
                fieldlist[0].Name = "BookingNumber";
                fieldlist[0].Alias = "BookingNumber";
                //create data set
                Microsoft.SqlServer.ReportingServices2005.DataSetDefinition dataSetDefinition = new Microsoft.SqlServer.ReportingServices2005.DataSetDefinition();
                dataSetDefinition.AccentSensitivitySpecified = false;
                dataSetDefinition.CaseSensitivitySpecified = false;
                dataSetDefinition.KanatypeSensitivitySpecified = false;
                dataSetDefinition.WidthSensitivitySpecified = false;
                //dataSetDefinition.Fields = fieldlist;
                Microsoft.SqlServer.ReportingServices2005.QueryDefinition queryDefition = new Microsoft.SqlServer.ReportingServices2005.QueryDefinition();                
                queryDefition.CommandText = "select top 1 Invoice_Id from DbTest1 order by Invoice_id Desc";
                queryDefition.CommandType = "Text";
                queryDefition.Timeout = 30;
                queryDefition.TimeoutSpecified = true;
                dataSetDefinition.Query = queryDefition;
                Microsoft.SqlServer.ReportingServices2005.DataSetDefinition results = new Microsoft.SqlServer.ReportingServices2005.DataSetDefinition();
                bool changed; string[] paramNames;
                    results = rsSubscription.PrepareQuery(delivery, dataSetDefinition, out changed, out paramNames);
                catch (SoapException ex)
                Microsoft.SqlServer.ReportingServices2005.DataRetrievalPlan dataRetrieval = new Microsoft.SqlServer.ReportingServices2005.DataRetrievalPlan();
                dataRetrieval.DataSet = results;
                dataRetrieval.Item = dataSourceDef;
                //set event type and match data
                //with matchdata we need to specify details like schedule for the subscription
                string EventType = "TimedSubscription";
                string matchData = @"<scheduledefinition>";
                matchData += @"<startdatetime>2012-10-25T18:35:00-07:00</startdatetime><weeklyrecurrence><weeksinterval>1</weeksinterval>";
                matchData += @"<daysofweek>";
                matchData += @"<monday>True</monday><tuesday>True</tuesday><wednesday>True</wednesday><thursday>True</thursday><friday>True</friday>";
                matchData += @"</daysofweek></weeklyrecurrence></scheduledefinition>";
                //set report parameter value
                //the parameter value is based on the field salesorderid created in the field list
                //thus the parameter will have as many values as the number of records in the
                //table OrderForDDS and those many reports will be delivered to the windows file
                Microsoft.SqlServer.ReportingServices2005.ParameterValueOrFieldReference[] parameters = new Microsoft.SqlServer.ReportingServices2005.ParameterValueOrFieldReference[1];
                Microsoft.SqlServer.ReportingServices2005.ParameterFieldReference param = new Microsoft.SqlServer.ReportingServices2005.ParameterFieldReference();
                Microsoft.SqlServer.ReportingServices2005.ParameterValue pvalue = new Microsoft.SqlServer.ReportingServices2005.ParameterValue();
                pvalue.Label = "vcBookingNum";
                pvalue.Name = "vcBookingNum";
                pvalue.Value = "12345";
                parameters[0] = pvalue;
                    string subscriptionID = rsSubscription.CreateDataDrivenSubscription(report, settings, dataRetrieval, description, EventType, matchData, pvalue);
                catch (SoapException ex)

Original Subject: The required field Field is missing from the input structure. ---> Microsoft.ReportingServices.Diagnostics.Utilities.MissingElementException: The required field Field is missing from the input...
Posted 8-Nov-12 0:47am
Edited 8-Nov-12 0:57am
(no name)84.9K
Slacker007 at 8-Nov-12 6:59am
What form of debugging or troubleshooting have you done so far? You might want to set a breakpoint and step through the code line by line. Just a thought.
Member 8001095 at 8-Nov-12 7:44am
The code fails and throws exceptions in this line:
string subscriptionID = rsSubscription.CreateDataDrivenSubscription(report, settings, dataRetrieval, description, EventType, matchData, pvalue);

The results for Prepare query works fine.
I tried changing configuration in the Report server. Set Unattended execution account as i was getting the Execption : Unattended Execution account expected.

After this error is solved, Field missing exception is coming up.
Not finding any solution for this
Slacker007 at 8-Nov-12 8:38am
Field missing sounds to me that you are either trying to pass to many fields(parameters) to this service or you are not passing enough. I would look into this.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
0 Sergey Alexandrovich Kryukov 524
1 OriginalGriff 245
2 Peter Leow 194
3 Abhinav S 102
4 Suvendu Shekhar Giri 95
0 OriginalGriff 9,428
1 Sergey Alexandrovich Kryukov 9,037
2 CPallini 5,189
3 Maciej Los 4,991
4 Mika Wendelius 3,856

Advertise | Privacy | Mobile
Web04 | 2.8.150819.1 | Last Updated 8 Nov 2012
Copyright © CodeProject, 1999-2015
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100