1 Replies - 286 Views - Last Post: 12 October 2011 - 10:00 PM Rate Topic: -----

#1 wan11  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 19
  • Joined: 09-August 11

Probleam: probleam with sql command

Posted 12 October 2011 - 09:12 PM

Hai i got a probleam with my sql command for update. Please advice me how i able to correct my command The error which i got got is Incorrect syntax near Total.Here is may code. I also highlight the line which cause me and error



Try
Connect = New OleDbConnection("Provider=SQLOLEDB ;Data Source=Danawa;Initial Catalog=Store;Integrated Security=SSPI ")
Connect.Open()
cmd = New OleDbCommand ("UPDATE ItemIn SET Itemquantity= Itemquantity - '" & ItemquantityTextBox.Text & "AND" & "'Total= Total -'" & total.Text & "'WHERE ItemName= '" & ItemNameComboBox.Text & "' ", Connect) / i got an error in this line
ra = cmd.ExecuteNonQuery()
Catch ex As Exception
MsgBox(ex.Message)
End Try
MsgBox(" Purchase Successfull ", MsgBoxStyle.Information)
Connect.Close()

Is This A Good Question/Topic? 0
  • +

Replies To: Probleam: probleam with sql command

#2 smohd  Icon User is offline

  • Critical Section
  • member icon


Reputation: 1752
  • View blog
  • Posts: 4,409
  • Joined: 14-March 10

Re: Probleam: probleam with sql command

Posted 12 October 2011 - 10:00 PM

Do you know how this part will be rad in database?'" & ItemquantityTextBox.Text & "AND" & "'Total= Total -'" & total.Text & "'? It will be like
'Good AND' Total= Total - '8'

Things to notice:
- You put AND in single quote with item quality together as one thing.
- You put value from text box in single quote then try to minus it with something unknown in database
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1