Wrox Home  
Search P2P Archive for: Go

  Return to Index  

access_asp thread: Can't update checkbox value into database


Message #1 by "Yvonne" <yenwan77@y...> on Tue, 9 Jul 2002 15:12:57
I have a login form which allows user to enter old ic or new ic for 
identification. Then it will proceed to reply slip form which displays the 
user's information and also allow them to check on the several checkboxes 
in the form. However, checkboxes in my database were not updated. Please 
help. Here is the code.


***** This is update.asp *****
	<% 
						
	 'Set connection
     Dim conn
     Set conn = Server.CreateObject ("ADODB.Connection")
     conn.Open = "Provider=Microsoft.Jet.OLEDB.4.0; Data Source=" & _
			Server.MapPath("/test/ReplyData.mdb")
	
	 'Set recordset
     Dim rs
     Set rs = Server.CreateObject("ADODB.Recordset")
     
     strSQL = "SELECT * FROM ReplyData " _
	 & "WHERE NewIC='" & Request.Form("newic") & "'"

     rs.Open strSQL, "DSN=ReplyData"

    
	Dim atten
	Dim newic
	
	newic = Request.Form("txtnewic")
	
	If Request.Form("chkAtten") = "-1" Then
		atten = "-1"
		
        update_SQL = "UPDATE ReplyData SET Atten = '" & -1 & "' WHERE 
NewIC = '" & Request.Form("txtnewic") & "'"
		
conn.Execute(update_SQL)
	Else
		atten = "0"
	End If
	'End If
	
		
	Response.Write(atten)						
	
	'Loop	
		conn.Close
		Set conn = Nothing
		rs.Close
		Set rs = Nothing
	%>
Message #2 by "Yvonne" <yenwan77@y...> on Tue, 9 Jul 2002 15:17:16
I have a login form which allows user to enter old ic or new ic for 
identification. Then it will proceed to reply slip form which displays the 
user's information and also allow them to check on the several checkboxes 
in the form. However, checkboxes in my database were not updated. From my 
understanding, this update.asp page couldn't get the value of the newic 
from the login page which user entered. Please help. Here is the code.


***** This is update.asp *****
	<% 
						
	 'Set connection
     Dim conn
     Set conn = Server.CreateObject ("ADODB.Connection")
     conn.Open = "Provider=Microsoft.Jet.OLEDB.4.0; Data Source=" & _
			Server.MapPath("/test/ReplyData.mdb")
	
	 'Set recordset
     Dim rs
     Set rs = Server.CreateObject("ADODB.Recordset")
     
     strSQL = "SELECT * FROM ReplyData " _
	 & "WHERE NewIC='" & Request.Form("newic") & "'"

     rs.Open strSQL, "DSN=ReplyData"

    
	Dim atten
	Dim newic
	
	newic = Request.Form("txtnewic")
	
	If Request.Form("chkAtten") = "-1" Then
		atten = "-1"
		
        update_SQL = "UPDATE ReplyData SET Atten = '" & -1 & "' WHERE 
NewIC = '" & Request.Form("txtnewic") & "'"
		
conn.Execute(update_SQL)
	
Else
		atten = "0"
	End If
		
		
	Response.Write(atten)						
	
	
		conn.Close
		Set conn = Nothing
		rs.Close
		Set rs = Nothing
	%>
Message #3 by "Larry Woods" <larry@l...> on Tue, 9 Jul 2002 07:44:06 -0700
What is this? :

update_SQL = "UPDATE ReplyData SET Atten = '" & -1 & "' WHERE
NewIC = '" & Request.Form("txtnewic") & "'"

Don't you want something like this?:

update_SQL = "UPDATE ReplyData SET Atten = '" & atten & "' WHERE
NewIC = '" & Request.Form("txtnewic") & "'"

This is assuming that the field Atten in your database is text.
If it isn't, then you don't want the single-quotes around the
stored value.

Larry Woods


> -----Original Message-----
> From: Yvonne [mailto:yenwan77@y...]
> Sent: Tuesday, July 09, 2002 3:13 PM
> To: Access ASP
> Subject: [access_asp] Can't update checkbox value into database
>
>
> I have a login form which allows user to enter old ic
> or new ic for
> identification. Then it will proceed to reply slip
> form which displays the
> user's information and also allow them to check on the
> several checkboxes
> in the form. However, checkboxes in my database were
> not updated. Please
> help. Here is the code.
>
>
> ***** This is update.asp *****
> 	<%
>
> 	 'Set connection
>      Dim conn
>      Set conn = Server.CreateObject ("ADODB.Connection")
>      conn.Open = "Provider=Microsoft.Jet.OLEDB.4.0;
> Data Source=" & _
> 			Server.MapPath("/test/ReplyData.mdb")
>
> 	 'Set recordset
>      Dim rs
>      Set rs = Server.CreateObject("ADODB.Recordset")
>
>      strSQL = "SELECT * FROM ReplyData " _
> 	 & "WHERE NewIC='" & Request.Form("newic") & "'"
>
>      rs.Open strSQL, "DSN=ReplyData"
>
>
> 	Dim atten
> 	Dim newic
>
> 	newic = Request.Form("txtnewic")
>
> 	If Request.Form("chkAtten") = "-1" Then
> 		atten = "-1"
>
>         update_SQL = "UPDATE ReplyData SET Atten = '"
> & -1 & "' WHERE
> NewIC = '" & Request.Form("txtnewic") & "'"
>
> conn.Execute(update_SQL)
> 	Else
> 		atten = "0"
> 	End If
> 	'End If
>
>
> 	Response.Write(atten)
>
> 	'Loop
> 		conn.Close
> 		Set conn = Nothing
> 		rs.Close
> 		Set rs = Nothing
> 	%>

Message #4 by Yvonne Woo <yenwan77@y...> on Tue, 9 Jul 2002 22:30:59 -0700 (PDT)
--0-37041404-1026279059=:50958
Content-Type: text/plain; charset=us-ascii


 Hi,
For your information, the field Atten in my database is data type boolean Yes/No value. I tried to insert atten in the stored value
but it couldn't work too. Thanks for your help.
Regards,
Yvonne
  Larry Woods <larry@l...> wrote: What is this? :

update_SQL = "UPDATE ReplyData SET Atten = '" & -1 & "' WHERE
NewIC = '" & Request.Form("txtnewic") & "'"

Don't you want something like this?:

update_SQL = "UPDATE ReplyData SET Atten = '" & atten & "' WHERE
NewIC = '" & Request.Form("txtnewic") & "'"

This is assuming that the field Atten in your database is text.
If it isn't, then you don't want the single-quotes around the
stored value.

Larry Woods


> -----Original Message-----
> From: Yvonne [mailto:yenwan77@y...]
> Sent: Tuesday, July 09, 2002 3:13 PM
> To: Access ASP
> Subject: [access_asp] Can't update checkbox value into database
>
>
> I have a login form which allows user to enter old ic
> or new ic for
> identification. Then it will proceed to reply slip
> form which displays the
> user's information and also allow them to check on the
> several checkboxes
> in the form. However, checkboxes in my database were
> not updated. Please
> help. Here is the code.
>
>
> ***** This is update.asp *****
> >
> 	 'Set connection
>      Dim conn
>      Set conn = Server.CreateObject ("ADODB.Connection")
>      conn.Open = "Provider=Microsoft.Jet.OLEDB.4.0;
> Data Source=" & _
> 			Server.MapPath("/test/ReplyData.mdb")
>
> 	 'Set recordset
>      Dim rs
>      Set rs = Server.CreateObject("ADODB.Recordset")
>
>      strSQL = "SELECT * FROM ReplyData " _
> 	 & "WHERE NewIC='" & Request.Form("newic") & "'"
>
>      rs.Open strSQL, "DSN=ReplyData"
>
>
> 	Dim atten
> 	Dim newic
>
> 	newic = Request.Form("txtnewic")
>
> 	If Request.Form("chkAtten") = "-1" Then
> 		atten = "-1"
>
>         update_SQL = "UPDATE ReplyData SET Atten = '"
> & -1 & "' WHERE
> NewIC = '" & Request.Form("txtnewic") & "'"
>
> conn.Execute(update_SQL)
> 	Else
> 		atten = "0"
> 	End If
> 	'End If
>
>
> 	Response.Write(atten)
>
> 	'Loop
> 		conn.Close
> 		Set conn = Nothing
> 		rs.Close
> 		Set rs = Nothing
> 	%>



*****************************************************
My Alternative E-Mail ----->

yenwan77@t...
ywwoo@h...

ICQ : 3838558


---------------------------------
Do You Yahoo!?
New! SBC Yahoo! Dial - 1st Month Free & unlimited access

  Return to Index