Solved

How is this insert statment writen?

Posted on 2009-05-04
11
197 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
Microsoft Certification Exam 74-409

Veeam® is happy to provide the Microsoft community with a study guide prepared by MVP and MCT, Orin Thomas. This guide will take you through each of the exam objectives, helping you to prepare for and pass the examination.

 
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

How Do You Stack Up Against Your Peers?

With today’s modern enterprise so dependent on digital infrastructures, the impact of major incidents has increased dramatically. Grab the report now to gain insight into how your organization ranks against your peers and learn best-in-class strategies to resolve incidents.

Question has a verified solution.

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

I'm trying, I really am. But I've seen so many wrong approaches involving date(time) boundaries I despair about my inability to explain it. I've seen quite a few recently that define a non-leap year as 364 days, or 366 days and the list goes on. …
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.
In Microsoft Access, learn how to use Dlookup and other domain aggregate functions and one method of specifying a string value within a string. Specify the first argument, which is the expression to be returned: Specify the second argument, which …
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …

679 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