Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

checkbox...

Status
Not open for further replies.

halukorhan1

IS-IT--Management
Oct 15, 2003
19
TR
Hi,

Imagine that I have a form with rows starting with the checkboxes. I would like to update a table. One of the fields in the table holds the status of the checkbox (true or false).

How can I update the field of this table if the checkboxes in the form are checked as True or unchecked as False?

Name of the checkbox field in the form is "local" and their values are starting from 1 to objRS.RecordCount .

Any help is appreciated...

Regards!

M. Haluk Orhan
 
in the next page u will get the value of the checkbox seperated by ,s. wouldnt that do???

Known is handfull, Unknown is worldfull
 


Hi,

My codes are given below...

But this one of course does not update the status of the unchecked fields. Because I used Request.Form("lokal").Count

I have to modify the codes to be able to get and assign status as False for the unchecked checkboxes and update the "lokal" field in the db according to status variable.

Regards!
----
for k = 1 to Request.Form("lokal").Count

lokal = Request.Form("lokal")(k)
d_gecis1 = "isciid" & lokal
d_isciid1 = Request.Form(d_gecis1)

SQL_update = "UPDATE TIscilikAnaliz"
SQL_update = SQL_update & " SET Lokal = True"
SQL_update = SQL_update & " WHERE IsciAnalizId = " & d_isciid1 & ""

Set objRS_update = Server.CreateObject ("ADODB.Recordset")
objRS_update.Open SQL_update, strConnect
----
 
a very simple way around is this:

SQL_update = "UPDATE TIscilikAnaliz"
SQL_update = SQL_update & " SET Lokal = False"
strConnect.execute SQL_update

for k = 1 to Request.Form("lokal").Count

lokal = Request.Form("lokal")(k)
d_gecis1 = "isciid" & lokal
d_isciid1 = Request.Form(d_gecis1)

SQL_update = "UPDATE TIscilikAnaliz"
SQL_update = SQL_update & " SET Lokal = True"
SQL_update = SQL_update & " WHERE IsciAnalizId = " & d_isciid1 & ""

Set objRS_update = Server.CreateObject ("ADODB.Recordset")
objRS_update.Open SQL_update, strConnect


how it works:
first all the records are set to false, then only checked records are set to true. therefore this will give the correct results.

Note:
i see that u are creating a recordset for every loop, when its update stmt then the following method is best:
Connection.execute sql

Known is handfull, Unknown is worldfull
 
Thanks for your help...

this sql_update is also inside a
Do while ... objRS.MoveNext : Loop

Do you think that it will cause a problem?

Could you explain me more how can I use
Connection.execute sql

Regards!
 
Connection -> Refers to ur connection object.

since update, insert and delete statements do not return results it is a waste to open a recordset. a recordset should be opened preferably only for select statements. it reduces load on your processor.

secondly even if u wann use a recordset in a loop do this:

Set objRS_update = Server.CreateObject ("ADODB.Recordset")
LOOP STARTS HERE
objRS_update.Open SQL_update, strConnect
objRS_update.close
ENDS HERE

that is a better method...

Known is handfull, Unknown is worldfull
 


Thanks for your help! It seems it is working but there is a slight problem. It updates all the data in the table as false, because we did not use "where" in the first SQL_update statement.

----
SQL_update = SQL_update & " WHERE IsciAnalizId = " & d_isciid1 & ""
----

Is there any other way to do it?

Regards
 
the idea is just that.

the first sql will update ALL files to false, the next query will update onlye THOSE SELECTED to true, isnt that what you wanted???

Known is handfull, Unknown is worldfull
 
no problemmo...

Known is handfull, Unknown is worldfull
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top