473,320 Members | 1,572 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

update checkbox values

I have an update page with Checkbox's, how can I get the value of the
checkbox and update the db table correctly?

heres the snippet i'm trying to run and its not working

strSQL = "update table1 set " & _
if chActive.checked = true then
"active='Yes'
end if

why will this not work?
Nov 18 '05 #1
3 1636
Hi Mike,

From the code you provided, you seems want to concate a certain sql
statement string depend on some checkbox's value, yes?

Your code is as
==================
strSQL = "update table1 set " & _
if chActive.checked = true then
"active='Yes'
end if
==================

the above code may cause compile error due to syntax problems. We should
change it as following
Dim strSQL As String
strSQL = "update table1 set"

If chActive.checked = True Then

strSQL = strSQL & "active='Yes'"

End If
Also, are you write the code directory in aspx file via <script
runat=server>......</script> block rather than using code behind? I
recommend that you use codebehind , that'll help avoid many syntax
mistakes. In addition, here is the reference on processing the asp.net
checkbox control's value in page code:

http://msdn.microsoft.com/library/en...gSettingCheckb
oxWebControlValueProgrammatically.asp?frame=true

Hope also helps. Thanks.

Regards,

Steven Cheng
Microsoft Online Support

Get Secure! www.microsoft.com/security
(This posting is provided "AS IS", with no warranties, and confers no
rights.)

Nov 18 '05 #2
not really the code below is actually part of an update SQL query. this is
just the part were i have to update the check box values and enter either
Yes or No in the DB depending if its checked or not

"Steven Cheng[MSFT]" <v-******@online.microsoft.com> wrote in message
news:9Y**************@cpmsftngxa10.phx.gbl...
Hi Mike,

From the code you provided, you seems want to concate a certain sql
statement string depend on some checkbox's value, yes?

Your code is as
==================
strSQL = "update table1 set " & _
if chActive.checked = true then
"active='Yes'
end if
==================

the above code may cause compile error due to syntax problems. We should
change it as following
Dim strSQL As String
strSQL = "update table1 set"

If chActive.checked = True Then

strSQL = strSQL & "active='Yes'"

End If
Also, are you write the code directory in aspx file via <script
runat=server>......</script> block rather than using code behind? I
recommend that you use codebehind , that'll help avoid many syntax
mistakes. In addition, here is the reference on processing the asp.net
checkbox control's value in page code:

http://msdn.microsoft.com/library/en...gSettingCheckb oxWebControlValueProgrammatically.asp?frame=true

Hope also helps. Thanks.

Regards,

Steven Cheng
Microsoft Online Support

Get Secure! www.microsoft.com/security
(This posting is provided "AS IS", with no warranties, and confers no
rights.)


Nov 18 '05 #3
Hi Mike,

Thanks for your followup. Does the CheckBox work ok now? I think you can
test the CheckBox on a simple page to confirm it. Also, remember to enable
the Page's ViewState. If you still have any questions, please feel free to
post here. Thanks.

Regards,

Steven Cheng
Microsoft Online Support

Get Secure! www.microsoft.com/security
(This posting is provided "AS IS", with no warranties, and confers no
rights.)

Get Preview at ASP.NET whidbey
http://msdn.microsoft.com/asp.net/whidbey/default.aspx

Nov 18 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Olivia Towery | last post by:
SQL 6.5 Database I have a list of registrants and I want to use a check box after each record to show those who attend and then post all with one submit button. Any help is appreciated. --...
0
by: Sue Adams | last post by:
I actually have two issues/questions: I have an autonumber field in an access db table that I grab and later use to update a record in another table withing the same db. The code I use to get...
2
by: Joe Fetters via .NET 247 | last post by:
Have googled and read the VS.NET documentation can't seem to getthe answer to the following. Environment: Framework 1.1 VB.NET WinForm Access database Using all automagic tools (DataAdapter...
1
by: hazz | last post by:
What do I do to capture the checkbox values as listed below in order to update the database table. There will be an ID field also contained in the row to use in the update query. What would I put...
16
by: Ian Davies | last post by:
Hello Needing help with a suitable solution. I have extracted records into a table under three columns 'category', 'comment' and share (the category column also holds the index no of the record...
3
by: mountain.dog | last post by:
I have a query that shows a list of options that a user can toggle on or off using a checkbox. query... form... while($row = mysql_fetch_array($result))... <input name="menu_show_attribute"...
1
by: hmlarson | last post by:
I have a form/table with checkboxes that I would like the user to check / uncheck if they want a certain record to display in a gallery on a website. I'm having problems figuring out how to...
11
by: TechnoAtif | last post by:
INSERT AND UPDATE MULTIPLE CHECKBOX DATA USING PHPMYSQL OR JAVASCRIPT Hi All I want to check the multiple checkboxes update them after revisiting that page. I am taking the name as...
2
by: sirdavethebrave | last post by:
Hi guys - I have written a form, and a stored procedure to update the said form. It really is as simple as that. A user can go into the form, update some fields and hit the update button to...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.