2 Replies - 197 Views - Last Post: 12 July 2013 - 04:28 AM Rate Topic: -----

#1 786_student  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 20
  • Joined: 29-June 13

Problem in MS Access query

Posted 12 July 2013 - 03:58 AM

Hi!

We are getting a problem in one query..

str = "Update SetDeduction set PFD = ' "  + TextBox1.Text +  " ' where PFD < '  "  + TextBox1.Text +  " '  And PFD <> ' 0 ' "



We found out that the query is partially working. We want that the PFD value gets updated for those employees who have non-zero value but not for those employees who have higher value of PFD willingly(for eg..20% instead of 12%).

When we run the code, it recognizes that which values are zero and which are non-zero (i.e., this part is working : PFD<> ' 0 ' ) but this part is not working : PFD < ' " + TextBox1.Text + " '

Is there any problem with the AND operator or the < operator ?

Also, in the tables we have PFD value as text so is this creating problem ? We tried this also :

Dim a As Integer 
a = Convert.ToInt32(TextBox1.Text)
str = "Update SetDeduction set PFD = ' "  + TextBox1.Text +  " ' where PFD < '  "  + Convert.ToInt32(TextBox1.Text)   " '  And PFD <> ' 0 ' "




but this also doesn't work.

Similarly we made tried converting the PFD also to integer by using OleDbDataReader but it did not work.

No errors are shown.

Can anyone help regarding this ?

Thanks!

Is This A Good Question/Topic? 0
  • +

Replies To: Problem in MS Access query

#2 andrewsw  Icon User is online

  • Fire giant boob nipple gun!
  • member icon

Reputation: 3252
  • View blog
  • Posts: 10,903
  • Joined: 12-December 12

Re: Problem in MS Access query

Posted 12 July 2013 - 04:22 AM

0 is a number and doesn't require apostrophes around it, nor does the other number that you are converting.

You are including unnecessary spaces in your expressions. Effectively, your are comparing ' hello ' which does not match 'hello'.

This post has been edited by andrewsw: 12 July 2013 - 04:23 AM

Was This Post Helpful? 0
  • +
  • -

#3 786_student  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 20
  • Joined: 29-June 13

Re: Problem in MS Access query

Posted 12 July 2013 - 04:28 AM

the comparison with 0 is working fine..in actual code spaces are not der and i put apostrophes around it because its type is text in the database.

the problem is with this part : PFD < '" + TextBox1.Text + "'
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1