Solved

How is this insert statment writen?

Posted on 2009-05-04
11
199 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
Windows Server 2016: All you need to know

Learn about Hyper-V features that increase functionality and usability of Microsoft Windows Server 2016. Also, throughout this eBook, you’ll find some basic PowerShell examples that will help you leverage the scripts in your environments!

 
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

Visualize your virtual and backup environments

Create well-organized and polished visualizations of your virtual and backup environments when planning VMware vSphere, Microsoft Hyper-V or Veeam deployments. It helps you to gain better visibility and valuable business insights.

Question has a verified solution.

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

Access developers frequently have requirements to interact with Excel (import from or output to) in their applications.  You might be able to accomplish this with the TransferSpreadsheet and OutputTo methods, but in this series of articles I will di…
In this series, we will discuss common questions received as a database Solutions Engineer at Percona. In this role, we speak with a wide array of MySQL and MongoDB users responsible for both extremely large and complex environments to smaller singl…
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…
Do you want to know how to make a graph with Microsoft Access? First, create a query with the data for the chart. Then make a blank form and add a chart control. This video also shows how to change what data is displayed on the graph as well as form…

724 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