ERROR [07002] [Microsoft][ODBC TextDriver] Too few parameters. Expected 6 RRS feed

  • Question

  • I'm trying to retrieve data from my text file using ODBC connection. But ending up with exception as below,

    System.Data.Odbc.OdbcException (0x80131937): ERROR [07002] [Microsoft][ODBC TextDriver] Too few parameters. Expected 6.

    Code :

        string Select = "SELECT ID As COL_ID, D As COL_Date, SUB As COL_DES, COL4, COL5 As COL_REP " +
    "FROM file.txt WHERE COLUMN = 'A'"; // Create the odbc connection OdbcConnection odbcConn = new OdbcConnection(connectionString); OdbcDataAdapter odbcDa = new OdbcDataAdapter(); odbcDa.SelectCommand = new OdbcCommand(); odbcDa.SelectCommand.Connection = odbcConn;

    This windows service is now running in 2012 Windows server(Migration from 2008 server). Please note same code and operation works in 2008. Could someone help me to pick why 2012 is throwing exception for Windows service which runs smooth in 2008

    • Edited by V_Anonymous Wednesday, February 1, 2017 10:26 PM
    Wednesday, February 1, 2017 1:33 AM

All replies

  • This exception generally indicates that one or more column names in your SQL statement cannot be resolved. Are you using a header with the column names in the text file? I can't see the connection string so I do not know whether this is specified.

    With no header the default column names for a text file are F1, F2, F3, etc. That is, unless you are using a schema.ini file.

    Paul ~~~~ Microsoft MVP (Visual Basic)

    Thursday, February 2, 2017 3:26 PM