Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
CODE PROJECT For Those Who Code
  • Home
  • Articles
  • FAQ
Community
  1. Home
  2. Database & SysAdmin
  3. Database
  4. Syntax error raised while insert a record into msaccess from VB.NET

Syntax error raised while insert a record into msaccess from VB.NET

Scheduled Pinned Locked Moved Database
csharpdatabasehelp
4 Posts 4 Posters 1 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • S Offline
    S Offline
    sivakumar mariappan
    wrote on last edited by
    #1

    Hi, I am inserting records into ms access using vb.net. insert into data(F01,F02)values(" & F01(k) & "," & IIf(Double.IsNaN(F01TA(k)), DBNull.Value, F01TA(k)) & ")" Showing syntax error in the insert statement. the output query is like below insert into Data(F01,F02)values(221,); Please share your ideas... Thanks, Sivakumar.M.

    M V D 3 Replies Last reply
    0
    • S sivakumar mariappan

      Hi, I am inserting records into ms access using vb.net. insert into data(F01,F02)values(" & F01(k) & "," & IIf(Double.IsNaN(F01TA(k)), DBNull.Value, F01TA(k)) & ")" Showing syntax error in the insert statement. the output query is like below insert into Data(F01,F02)values(221,); Please share your ideas... Thanks, Sivakumar.M.

      M Offline
      M Offline
      Md Marufuzzaman
      wrote on last edited by
      #2

      check the value of the given parameters... your generated query probably like ... ....Values(1,2,,3)

      I will not say I have failed 1000 times; I will say that I have discovered 1000 ways that can cause failure – Thomas Edison.


      Don't forget to click [Vote] / [Good Answer] on the post(s) that helped you. Thanks Md. Marufuzzaman

      1 Reply Last reply
      0
      • S sivakumar mariappan

        Hi, I am inserting records into ms access using vb.net. insert into data(F01,F02)values(" & F01(k) & "," & IIf(Double.IsNaN(F01TA(k)), DBNull.Value, F01TA(k)) & ")" Showing syntax error in the insert statement. the output query is like below insert into Data(F01,F02)values(221,); Please share your ideas... Thanks, Sivakumar.M.

        V Offline
        V Offline
        Vimalsoft Pty Ltd
        wrote on last edited by
        #3

        What is the Error that you are getting ? Your insert is incorrect, Your expected number of parameters is less than the Supplied Parameters.

        Vuyiswa Maseko, Few companies that installed computers to reduce the employment of clerks have realized their expectations.... They now need more and more expensive clerks even though they call them "Developers" or "Programmers." C#/VB.NET/ASP.NET/SQL7/2000/2005/2008 http://www.vuyiswamaseko.com vuyiswa@its.co.za http://www.itsabacus.co.za/itsabacus/

        1 Reply Last reply
        0
        • S sivakumar mariappan

          Hi, I am inserting records into ms access using vb.net. insert into data(F01,F02)values(" & F01(k) & "," & IIf(Double.IsNaN(F01TA(k)), DBNull.Value, F01TA(k)) & ")" Showing syntax error in the insert statement. the output query is like below insert into Data(F01,F02)values(221,); Please share your ideas... Thanks, Sivakumar.M.

          D Offline
          D Offline
          David Skelly
          wrote on last edited by
          #4

          When you concatenate DBNull.Value into your query expression, it calls the DBNull.ToString method. This is defined to return an empty string, so your insert statement is missing a parameter after the final comma. Use the literal "null" in your SQL insert instead of DBNull.Value, that should work. Or use a DbCommand with query parameters, as someone else suggested.

          1 Reply Last reply
          0
          Reply
          • Reply as topic
          Log in to reply
          • Oldest to Newest
          • Newest to Oldest
          • Most Votes


          • Login

          • Don't have an account? Register

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • World
          • Users
          • Groups