V
Vagabond Software
The problem is that this worked fine on my Windows XP machine, but did not work on any of several Windows 2000 computers at the client's location. The Select method would always return 0 (zero) rows even though we were working with the exact same list of files in both locations.
As part of some experimentation, I changed the Type of the "LastModified" from "System.DateTime" to "System.String" and everything began working as expected at the client's location.
If anyone has any clue as to why I cannot use the "System.DateTime" DataColumn type in the client's Windows 2000 environment when it works perfectly in my Windows XP environment; I would greatly appreciate any input.
Here are the relevant code snippets:
--- DataTable & Column Info ---
this.fileinfo = new DataTable("TestFileInfo");
this.fileinfo.Columns.Add("FileName", Type.GetType("System.String"));
this.fileinfo.Columns.Add("FileSize", Type.GetType("System.UInt64"));
/* DEBUG BEGIN: The following line does not work in client environment...
this.fileinfo.Columns.Add("LastModified", Type.GetType("System.DateTime"));
*/
this.fileinfo.Columns.Add("LastModified", Type.GetType("System.String"));
/* DEBUG END */
this.fileinfo.Columns.Add("FullPath", Type.GetType("System.String"));
--- DataTable Select method Info ---
string exprFile = "FileName LIKE '" + pattern + "*'";
string latestFileDate = dtFiles.Compute("MAX(LastModified)",
exprFile).ToString();
string exprDate = exprFile + " AND LastModified = '" +
latestFileDate + "'";
DataRow[] foundRows = dtFiles.Select(exprDate);
string latestFile = null;
if (foundRows.Length > 0)
latestFile = foundRows[0]["FullPath"].ToString();
return latestFile;
The above code returns 0 (zero) rows if "LastModified" DataColumn type set to System.DateTime.
- carl
As part of some experimentation, I changed the Type of the "LastModified" from "System.DateTime" to "System.String" and everything began working as expected at the client's location.
If anyone has any clue as to why I cannot use the "System.DateTime" DataColumn type in the client's Windows 2000 environment when it works perfectly in my Windows XP environment; I would greatly appreciate any input.
Here are the relevant code snippets:
--- DataTable & Column Info ---
this.fileinfo = new DataTable("TestFileInfo");
this.fileinfo.Columns.Add("FileName", Type.GetType("System.String"));
this.fileinfo.Columns.Add("FileSize", Type.GetType("System.UInt64"));
/* DEBUG BEGIN: The following line does not work in client environment...
this.fileinfo.Columns.Add("LastModified", Type.GetType("System.DateTime"));
*/
this.fileinfo.Columns.Add("LastModified", Type.GetType("System.String"));
/* DEBUG END */
this.fileinfo.Columns.Add("FullPath", Type.GetType("System.String"));
--- DataTable Select method Info ---
string exprFile = "FileName LIKE '" + pattern + "*'";
string latestFileDate = dtFiles.Compute("MAX(LastModified)",
exprFile).ToString();
string exprDate = exprFile + " AND LastModified = '" +
latestFileDate + "'";
DataRow[] foundRows = dtFiles.Select(exprDate);
string latestFile = null;
if (foundRows.Length > 0)
latestFile = foundRows[0]["FullPath"].ToString();
return latestFile;
The above code returns 0 (zero) rows if "LastModified" DataColumn type set to System.DateTime.
- carl