Jump to content


Check out our Community Blogs

Register and join over 40,000 other developers!


Recent Status Updates

View All Updates

Photo
- - - - -

DataTable.Select - SyntaxErrorException

runtime syntax

  • Please log in to reply
1 reply to this topic

#1 Javadocs

Javadocs

    CC Newcomer

  • Just Joined
  • PipPip
  • 11 posts

Posted 02 July 2009 - 08:29 AM

Updated: I changed a string element for the better that made it think it was a dateTime, but now I'm getting a SyntaxErrorException at runtime. I'm using backslashes for file directory locations, and it is my primary key, but appearently I can't do that?

System.Data.SyntaxErrorException was unhandled
  Message="Cannot interpret token '\\' at position 8."
  Source="System.Data"
  StackTrace:
       at System.Data.ExpressionParser.Scan()
       at System.Data.ExpressionParser.Parse()
       at System.Data.DataExpression..ctor(DataTable table, String expression, Type type)
       at System.Data.Select..ctor(DataTable table, String filterExpression, String sort, DataViewRowState recordStates)
       at System.Data.DataTable.Select(String filterExpression)
       at ServerScanCompare.FileScanCompare.FileCompare(DataTable dtbScanResults) in C:\Documents and Settings\441051\My Documents\Visual Studio 2008\Projects\ServerScanCompare\ServerScanCompare\FileScanCompare.cs:line 64
       at ServerScanCompare.FileScanCompare.RunFileScanCompare(String szSearchArgs, String[] szServer, String[] szSharedResource) in C:\Documents and Settings\441051\My Documents\Visual Studio 2008\Projects\ServerScanCompare\ServerScanCompare\FileScanCompare.cs:line 45
       at ServerScanCompare.MainGUI..ctor() in C:\Documents and Settings\441051\My Documents\Visual Studio 2008\Projects\ServerScanCompare\ServerScanCompare\MainGUI.cs:line 20
       at ServerScanCompare.Program.Main() in C:\Documents and Settings\441051\My Documents\Visual Studio 2008\Projects\ServerScanCompare\ServerScanCompare\Program.cs:line 19
       at System.AppDomain._nExecuteAssembly(Assembly assembly, String[] args)
       at System.AppDomain.ExecuteAssembly(String assemblyFile, Evidence assemblySecurity, String[] args)
       at Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly()
       at System.Threading.ThreadHelper.ThreadStart_Context(Object state)
       at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
       at System.Threading.ThreadHelper.ThreadStart()
  InnerException: 

And my code that is erroring out is this:
public DataSet FileCompare(DataTable dtbScanResults)
        {
            //create the dataset
            DataSet dsFileCompareResults = new DataSet("FileCompareResults");

            //add the tables to the data set
            dsFileCompareResults.Tables.Add(dtbScanResults);
            dsFileCompareResults.Tables.Add(CreateNewFileNameTable("FileNameFlags"));

            //search the dtb results for differing files
            foreach(DataRow drPrimaryRow in dtbScanResults.Rows) {
                if((bool)drPrimaryRow["FlaggedFile"] != true)
                {
                    foreach(DataRow drComparedRow in [B]dtbScanResults.Select(drPrimaryRow["FileDirectoryLocation"].ToString())[/B])
                    {

....
Bolded is the line that errors.

Other information that may be relevant:
  • The DataTable that is put in as a parameter has 7 Columns. The first 6 are string types, and the last is a bool type.
  • The primary keys of the table are "FileFullPath" and "FileDirectoryLocation" which are both string types. FileFullPath is unique, but FileDirectoryLocation is not.
  • The string returned from dtbScanResults.Select(drPrimaryRow["FileDirectoryLocation"].ToString() is "//export//", it is /export/ in the DataTable

  • 0

#2 Javadocs

Javadocs

    CC Newcomer

  • Just Joined
  • PipPip
  • 11 posts

Posted 02 July 2009 - 08:51 AM

Bah, yet again, I solved it myself. Sorry for wasting your time if you tried to help at all. The parameters in the DataTable.Select wanted an expression, I just gave what I wanted to search and assumed it would know what to search.
  • 0





Also tagged with one or more of these keywords: runtime, syntax

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download