|
-
Aug 1st, 2004, 04:13 AM
#1
Thread Starter
New Member
How to combine Insert and Where clause together??
Hi, I really need help here...
I want to update an 'avaibility' as in yes/no in the database..
Its subjected to only that particular serial number...
Heres my code.
Dim cmdTemp As OleDb.OleDbCommand
cmdTemp = New OleDb.OleDbCommand
cmdTemp.CommandType = CommandType.Text
cmdTemp.Connection = cnnRental
cmdTemp.CommandText = "INSERT INTO Stock (existance) VALUES ('0')"[COLOR=red] <--- how do i add the clause "Where serial = txtSerial.text or '?' to make it to a complete statement?"
cmdTemp.Connection.Open() cmdTemp.ExecuteNonQuery() cmdTemp.Connection.Close
-
Aug 1st, 2004, 07:00 AM
#2
New Member
Hello,
if I understand you correctly:
use UPDATE instad of INSERT.
VB Code:
UPDATE Stock (existance) VALUES ('0') Where serial = '" & txtSerial.text & "'
-
Aug 1st, 2004, 07:13 AM
#3
Thread Starter
New Member
Hi,
I tried the following command...
cmdTemp.CommandText = "UPDATE Stock (existance) VALUES ('false') Where serial_number = '" + txbRentalSerial.Text + "'"
It gives me "syntax error in Update statement" @@
Can i use 'false' as the existance is yes/no in access...
I tried using '0' too... to no avail.. :_(
-
Aug 1st, 2004, 07:18 AM
#4
New Member
try this...
VB Code:
cmdTemp.CommandText = "UPDATE Stock SET (existance) VALUES ('no') Where serial_number = " & txbRentalSerial.Text
or
VB Code:
cmdTemp.CommandText = "UPDATE Stock SET existance='no' Where serial_number = " & txbRentalSerial.Text
-
Aug 1st, 2004, 11:46 PM
#5
Thread Starter
New Member
Thanks Chris,
cmdTemp.CommandText = "UPDATE Stock SET existance=false Where serial_number = " & LngNumber
the above command helps... just that i need to make the textbox Clng() before i can pass it in... as i declared serial number as long integer. for the yest/no should put in a true/false instead.
Thanks a million..
Regards,
Henry
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|