Solved

How is this insert statment writen?

Posted on 2009-05-04
11
196 Views
Last Modified: 2012-05-06
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
Comment
Question by:Mickeys
  • 6
  • 4
11 Comments
 
LVL 61

Expert Comment

by:mbizup
ID: 24296611
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
 
LVL 61

Expert Comment

by:mbizup
ID: 24296638
The WHERE clause is what made me think you were working with existing records (UPDATE) versus adding new ones (INSERT)
0
 

Author Comment

by:Mickeys
ID: 24296677
ah update it is.

so is this correct?
"UPDATE Customers SET bVisible=true WHERE (CustomerID) ='" + RemoveTextBox.Text + "'";
0
Master Your Team's Linux and Cloud Stack

Come see why top tech companies like Mailchimp and Media Temple use Linux Academy to build their employee training programs.

 
LVL 61

Expert Comment

by:mbizup
ID: 24296704
That looks good... Give it a whirl.
0
 

Author Comment

by:Mickeys
ID: 24296812
hmm it runs the query but the checkbox keeps beeing empty
0
 

Author Comment

by:Mickeys
ID: 24296855
if i only run

UPDATE Customers SET bVisible=true
all gets set

but if I add where nothing happens.
0
 
LVL 40

Expert Comment

by:Sharath
ID: 24297188
Do you have your CustomerId in this box, RemoveTextBox.Text ?
give a try.
"UPDATE Customers SET bVisible=true WHERE CustomerID ='" + RemoveTextBox.Text + "'";
0
 
LVL 61

Accepted Solution

by:
mbizup earned 500 total points
ID: 24297483
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
 
LVL 61

Expert Comment

by:mbizup
ID: 24297510
Also, is your user interface written in VB or Access VBA?
0
 

Author Comment

by:Mickeys
ID: 24298330
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
 
LVL 61

Expert Comment

by:mbizup
ID: 24298603
Glad you got it sorted!  :)
0

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

CCModeler offers a way to enter basic information like entities, attributes and relationships and export them as yEd or erviz diagram. It also can import existing Access or SQL Server tables with relationships.
As technology users and professionals, we’re always learning. Our universal interest in advancing our knowledge of the trade is unmatched by most industries. It’s a curiosity that makes sense, given the climate of change. Within that, there lies a…
Video by: Steve
Using examples as well as descriptions, step through each of the common simple join types, explaining differences in syntax, differences in expected outputs and showing how the queries run along with the actual outputs based upon a simple set of dem…
In Microsoft Access, learn the trick to repeating sub-report headings at the top of each page. The problem with sub-reports and headings: Add a dummy group to the sub report using the expression =1: Set the “Repeat Section” property of the dummy…

839 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question