I'm not sure if this is where to start but I'm having an issue with displaying a datetime in an infopath 2013 form. Little background: this is an infopath 2013 form that is saved to a network location for users to enter data. My main connection is a connection to SQL 2017. I have a smalldatetime column on the SQL table called referralDateTime (smalldatetime; "2020-01-03 07:45:00". On my infopath form I have a text box/ready only that the returned date populates.
On the form a user enters a date range on the form, I pass those values using c#, then call a stored procedure which returns data based on the parameters I'm passing. This all works perfectly. However, when the referralDateTime is displayed on the infopath form, it displays the value as "3/1/2020 07:45:00 AM" but has the dotted red lines around the box. I have tried formatting the date with SQL to match that format in infopath, but still red lines. I am unsure how to format this to avoid the red lines on the text box. Here is the c# code that I'm using currently that does return the datetime value to the user screen:
// Reading in values from Stored Proc
SqlDataReader dataReader;
SqlDataAdapter da = new SqlDataAdapter(_oCommand);
DataSet ds = new DataSet();
da.Fill(ds, "RetrieveData_View");
dataReader = _oCommand.ExecuteReader();
// Create a navigator for the xpath doc or set of
XPathNavigator nav = MainDataSource.CreateNavigator().SelectSingleNode("/dfs:myFields/dfs:dataFields/d:TestReferrals", NamespaceManager);
XPathNavigator RetrieveData_View = nav.Clone();
MessageBox.Show("Please wait while data is retrieved...", "Referral Submission", MessageBoxButtons.OK, MessageBoxIcon.Information);
// This will read / loop through data being returned from Stored Procedure
while (dataReader.Read())
{
Global.dateTimeOfReferral = dataReader["DateTimeofReferral"].ToString();
RetrieveData_View.SelectSingleNode("/dfs:myFields/dfs:dataFields/d:TestReferrals/@DateTimeofReferral", NamespaceManager).SetValue(Global.dateTimeOfReferral);
RetrieveData_View.InsertAfter(RetrieveData_View);
} // END OF WHILE LOOP
// Deleting duplicate row retrieved
XPathNavigator firstNode = MainDataSource.CreateNavigator().SelectSingleNode("/dfs:myFields/dfs:dataFields/d:TestReferrals[1]", NamespaceManager);
firstNode.DeleteSelf();
dataReader.Close();
cnn.Close();
“Fight the fighters, not their wars.”
― Bansky