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
  1. Home
  2. Database & SysAdmin
  3. Database
  4. syntax error in insert into statement

syntax error in insert into statement

Scheduled Pinned Locked Moved Database
helpquestion
2 Posts 2 Posters 0 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.
  • M Offline
    M Offline
    magedhv
    wrote on last edited by
    #1

    this is the msg that show when iam trying to apply this code Dim f1, f2, f3, f4, f5, f6, f7, f8 As String f1 = "#" & DateTimePicker1.Value & "#," f2 = "'" & ComboBox1.Text & "'," f3 = "'" & ComboBox2.Text & "'," f4 = "'" & TextBox1.Text & "'," f5 = "'" & TextBox2.Text & "'," f6 = "'" & TextBox3.Text & "'," f7 = "'" & TextBox4.Text & "'," f8 = "'" & Label10.Text & "'" s = "insert into sale" s = s & " (dte,op,nos,cost,coms,nii,npp)values " s = s & "(" & f1 & "," & f2 & "," & f3 & "," & f4 & "," & "," & f5 & "," & "," & f6 & "," & f7 & "')" cmd.CommandText = s cmd.ExecuteNonQuery() MsgBox("Saved succssefuly") any suggestion ? plz help urgent

    K 1 Reply Last reply
    0
    • M magedhv

      this is the msg that show when iam trying to apply this code Dim f1, f2, f3, f4, f5, f6, f7, f8 As String f1 = "#" & DateTimePicker1.Value & "#," f2 = "'" & ComboBox1.Text & "'," f3 = "'" & ComboBox2.Text & "'," f4 = "'" & TextBox1.Text & "'," f5 = "'" & TextBox2.Text & "'," f6 = "'" & TextBox3.Text & "'," f7 = "'" & TextBox4.Text & "'," f8 = "'" & Label10.Text & "'" s = "insert into sale" s = s & " (dte,op,nos,cost,coms,nii,npp)values " s = s & "(" & f1 & "," & f2 & "," & f3 & "," & f4 & "," & "," & f5 & "," & "," & f6 & "," & f7 & "')" cmd.CommandText = s cmd.ExecuteNonQuery() MsgBox("Saved succssefuly") any suggestion ? plz help urgent

      K Offline
      K Offline
      Krish KP
      wrote on last edited by
      #2

      dte column looks datetime datatype

      magedhv wrote:

      s = s & "(" & f1 & "," & f2 & "," & f3 & "," & f4 & "," & "," & f5 & "," & "," & f6 & "," & f7 & "')"

      change the query to s = s & "('" & f1 & "'," & f2 & "," & f3 & "," & f4 & "," & "," & f5 & "," & "," & f6 & "," & f7 & "')" so that the date is incloded in single quotes

      Regards KP

      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