Solved

How is this insert statment writen?

Posted on 2009-05-04
11
198 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
Guide to Performance: Optimization & Monitoring

Nowadays, monitoring is a mixture of tools, systems, and codes—making it a very complex process. And with this complexity, comes variables for failure. Get DZone’s new Guide to Performance to learn how to proactively find these variables and solve them before a disruption occurs.

 
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 41

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

MS Dynamics Made Instantly Simpler

Make Your Microsoft Dynamics Investment Count  & Drastically Decrease Training Time by Providing Intuitive Step-By-Step WalkThru Tutorials.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Format Transaction Number 19 48
Add Underline to custom Caption on Label 4 34
Question about Common Table Expressions 3 42
T-SQL: Wrong Result 7 37
It’s the first day of March, the weather is starting to warm up and the excitement of the upcoming St. Patrick’s Day holiday can be felt throughout the world.
In Part II of this series, I will discuss how to identify all open instances of Excel and enumerate the workbooks, spreadsheets, and named ranges within each of those instances.
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that 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…

737 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