none
ERROR [42000] [Microsoft][ODBC Visual FoxPro Driver]Syntax error. RRS feed

  • Question

  • when i run a insert command , i meet this error at comm.ExecuteNonQuery() line

    Dim strCnnFF As String = "Dsn=Visual FoxPro Tables;sourcedb=c:\;sourcetype=DBF;

    exclusive=No;backgroundfetch=Yes;collate=Machine;null=Yes;deleted=Yes" Dim ConnFF As New System.Data.Odbc.OdbcConnection(strCnnFF) Dim comm As New OdbcCommand("insert into kar(dsk_id,dsk_name,dsk_farm,dsk_adrs,dsk_kind" _ & ",dsk_yy,dsk_mm,dsk_listno,dsk_num,dsk_tdd,dsk_trooz" _ & ",dsk_tmah,dsk_tmaz,dsk_tmash,dsk_ttotl,dsk_tbime,dsk_tkoso" _ & ",dsk_bic,dsk_rate,dsk_prate,dsk_bimh,mon_pym)" _ & " values(@id,@name,@farm,@adrs,@kind," _ & "@yy,@mm,@listno,@num,tdd,trooz," _ & "@tmah,@tmaz,@tmash,@ttotl,@tbime,tkoso," _ & "@bic,@rate,@prate,@bimh,@pym)", ConnFF) With ds.Tables(1) Dim id As New OdbcParameter("@id", ("")) Dim name As New OdbcParameter("@name", (Mid(.Rows(0)("karname").ToString.Trim, 1, 30))) Dim farm As New OdbcParameter("@farm", (.Rows(0)("karfname").ToString.Trim)) Dim adrs As New OdbcParameter("@adrs", (Mid(.Rows(0)("karadrs").ToString.Trim, 1, 40))) Dim kind As New OdbcParameter("@kind", 0) Dim yy As New OdbcParameter("@yy", (Mid(.Rows(0)("mon_yy"), 3, 2))) Dim mm As New OdbcParameter("@yy", (.Rows(0)("mon_mm"))) Dim listno As New OdbcParameter("@listno", (.Rows(0)("mon_seq").ToString.Trim)) Dim num As New OdbcParameter("@num", (.Rows(0)("mon_ted"))) Dim tdd As New OdbcParameter("@tdd", (.Rows(0)("mon_days"))) Dim trooz As New OdbcParameter("@trooz", (.Rows(0)("mon_rooz"))) Dim tmah As New OdbcParameter("@tmah", (.Rows(0)("mon_mah"))) Dim tmaz As New OdbcParameter("@tmaz", (.Rows(0)("mon_maz"))) Dim tmash As New OdbcParameter("@tmash", (.Rows(0)("mon_mash"))) Dim ttotl As New OdbcParameter("@ttotl", (.Rows(0)("mon_all"))) Dim tbime As New OdbcParameter("@tbime", (.Rows(0)("mon_7p"))) Dim tkoso As New OdbcParameter("@tkoso", (.Rows(0)("mon_20p"))) Dim bic As New OdbcParameter("@bic", (.Rows(0)("mon_3p"))) Dim rate As New OdbcParameter("@rate", (.Rows(0)("karrate"))) Dim prate As New OdbcParameter("@prate", 0) Dim bimh As New OdbcParameter("@bimh", (.Rows(0)("mon_4p"))) Dim pym As New OdbcParameter("@pym", (.Rows(0)("mon_pym").ToString.Trim)) comm.Parameters.AddRange(New OdbcParameter() {id, name, farm, adrs, kind, yy, mm, listno _ , num, tdd, trooz, tmah, tmaz, tmash, ttotl _ , tbime, tkoso, bic, rate, prate, bimh, pym}) comm.ExecuteNonQuery() End With




    • Edited by Ashkan209 Wednesday, February 8, 2012 4:51 AM
    Monday, February 6, 2012 8:44 AM

Answers

All replies

  • Hi Ashkan209,

    Welcome to MSDN Forum.

    The exception was thrown is caused by invalid T-SQL, please check the T-SQL.

    Best Regards


    Allen Li [MSFT]
    MSDN Community Support | Feedback to us

    Tuesday, February 7, 2012 8:32 AM
    Moderator
  • T-SQl ,No problem

    Because, when i change connection string to Jet4.Oledb and so Odbcparameter to Oledbparameter , i dont have any problem and The program works correctly .

    But I need to Odbc command and visual foxpro connection string , and when i use it ,I meet error on Comm.ExecuyeNonquery

    System.Data.Odbc.OdbcException was caught ErrorCode=-2146232009 Message=ERROR [42000] [Microsoft][ODBC Visual FoxPro Driver]Syntax error. Source=VFPODBC.DLL StackTrace: at System.Data.Odbc.OdbcConnection.HandleError(OdbcHandle hrHandle, RetCode retcode) at System.Data.Odbc.OdbcCommand.ExecuteReaderObject(CommandBehavior behavior,

    String method, Boolean needReader, Object[] methodArguments, SQL_API odbcApiMethod) at System.Data.Odbc.OdbcCommand.ExecuteReaderObject(CommandBehavior behavior,

    String method, Boolean needReader) at System.Data.Odbc.OdbcCommand.ExecuteNonQuery() InnerException:


    Wednesday, February 8, 2012 4:49 AM
  • Hi Ashkan209,

    Please try to use '?' replace of '@data'.

    Best Regards


    Allen Li [MSFT]
    MSDN Community Support | Feedback to us

    Wednesday, February 8, 2012 9:55 AM
    Moderator