• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 207
  • Last Modified:

How is this insert statment writen?

I want to add i table Customer
where my customerid = "MYCOMPANY"
and set the columb bVisible to checked (it is a box in the table)

INSERT INTO Customers (bVisible) VALUES(True) WHERE (CustomerID) = MYCOMPANY

is that correct?
0
Mickeys
Asked:
Mickeys
  • 6
  • 4
1 Solution
 
mbizupCommented:
Are you sure you do not need to UPDATE an existing record?
UPDATE Customers
SET bVisible = True WHERE CustomerID = 'MYCOMPANY'

INSERT adds a new record, Also, if CustomerID is text, you need quotes as shown.
0
 
mbizupCommented:
The WHERE clause is what made me think you were working with existing records (UPDATE) versus adding new ones (INSERT)
0
 
MickeysAuthor Commented:
ah update it is.

so is this correct?
"UPDATE Customers SET bVisible=true WHERE (CustomerID) ='" + RemoveTextBox.Text + "'";
0
Improve Your Query Performance Tuning

In this FREE six-day email course, you'll learn from Janis Griffin, Database Performance Evangelist. She'll teach 12 steps that you can use to optimize your queries as much as possible and see measurable results in your work. Get started today!

 
mbizupCommented:
That looks good... Give it a whirl.
0
 
MickeysAuthor Commented:
hmm it runs the query but the checkbox keeps beeing empty
0
 
MickeysAuthor Commented:
if i only run

UPDATE Customers SET bVisible=true
all gets set

but if I add where nothing happens.
0
 
SharathData EngineerCommented:
Do you have your CustomerId in this box, RemoveTextBox.Text ?
give a try.
"UPDATE Customers SET bVisible=true WHERE CustomerID ='" + RemoveTextBox.Text + "'";
0
 
mbizupCommented:
Can you post the full line of code?

"UPDATE Customers SET bVisible=true WHERE (CustomerID) ='" + RemoveTextBox.Text + "'";

Why is there a semicolon outside of the parentheses?


Give this a shot:

"UPDATE Customers SET bVisible=true WHERE (CustomerID) ='" + RemoveTextBox.Text + "';"

Then check the actual value held in RemoveTextBox.Text.

If it is not updating the records, it sounds like you do not have any records where CustomerID matches RemoveTextBox.Text.

Finally, please verify whether CustomerID is text or numeric in your database.
0
 
mbizupCommented:
Also, is your user interface written in VB or Access VBA?
0
 
MickeysAuthor Commented:
I found the error. I used RemoveTextBox..........when I should have used another named textbox. I had copy the text so the clue was from mbizup:  :-)

0
 
mbizupCommented:
Glad you got it sorted!  :)
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Improve Your Query Performance Tuning

In this FREE six-day email course, you'll learn from Janis Griffin, Database Performance Evangelist. She'll teach 12 steps that you can use to optimize your queries as much as possible and see measurable results in your work. Get started today!

  • 6
  • 4
Tackle projects and never again get stuck behind a technical roadblock.
Join Now