Click here to Skip to main content
15,896,912 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
VB
' next create a command
Dim CMD3 As New OleDb.OleDbCommand
SQL = "insert into reciptdetails"
      "(Reciptid,Barcode,Itemcount,Itembuyprice,Itemsellprice)"
      "values"
      "(:0    ,:1    ,:2    ,:3    ,:4       )"
Posted
Comments
Michael_Davies 1-Aug-15 3:05am    
You need to concatenate the strings across lines.

SQL = "insert into reciptdetails" _
& "(Reciptid,Barcode,Itemcount,Itembuyprice,Itemsellprice)" _
& "values" _
& "(:0 ,:1 ,:2 ,:3 ,:4 )"

You may then get and SQL failure as you have not put spaces between the string lines words so the result as it is will be

"insert into reciptdetails(Reciptid,Barcode,Itemcount,Itembuyprice,Itemsellprice)values(:0 ,:1 ,:2 ,:3 ,:4 )"

Which may or may not parse:

SQL = "insert into reciptdetails" _
& " (Reciptid,Barcode,Itemcount,Itembuyprice,Itemsellprice)" _
& " values" _
& " (:0 ,:1 ,:2 ,:3 ,:4 )"

I assume you are then going to paramterise the command if not then :0 etc. must be strings and ought to be single quoted i.e. ':0',':1' etc.

It looks like you're building a string from multiple parts . For this you have to use concatenation:
VB
SQL = "insert into reciptdetails" +
      " (Reciptid,Barcode,Itemcount,Itembuyprice,Itemsellprice)" +
      " values" +
      " (:0    ,:1    ,:2    ,:3    ,:4       )"
 
Share this answer
 
v2
VB
Dim CMD3 As New OleDb.OleDbCommand
Dim Sql As String
Sql = "insert into reciptdetails" +
    "(Reciptid,Barcode,Itemcount,Itembuyprice,Itemsellprice)" +
    "values" +
    "(:0    ,:1    ,:2    ,:3    ,:4       )"
 
Share this answer
 
v2
Solutions 1 and 2 are missing a detail:
- you need to add a space at the end of each pieces of the SQL command
VB
SQL = "insert into reciptdetails " +
      "(Reciptid,Barcode,Itemcount,Itembuyprice,Itemsellprice) " +
      "values " +
      "(:0    ,:1    ,:2    ,:3    ,:4       )"
 
Share this answer
 
variable is an enclosing block
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900