Hi Faisal,
First and foremost thanks for an awesome website. I have learned more from your website than any other.
I am trying to update an acess database using the foll code.
<html>
<body>
<p></p>
<%
dim array_email(10000)
dim array_sendval(10000)
lath_wrks_val=request.form("chk_lath_wrks")
lath_accs_val=request.form("chk_lath_accs")
strsql1="select * from users"
'strsql2="update users set send=5"
Set objDC = Server.CreateObject("ADODB.Connection")
objDC.Open Application("mail_connectionstring")
k=0
Set rs= objDC.Execute("Select * FROM users")
rs.movefirst
While Not rs.EOF
'initialize variables
lath_wrks_new=0
lath_accs_new=0
intermediate_lath_wrks_val=0
intermediate_lath_accs_val=0
email=rs("email")
lath_wrks_new=rs("lath_wrks")
lath_accs_new=rs("lath_accs")
intermediate_lath_wrks_val=(lath_wrks_new)*lath_wrks_val
intermediate_lath_accs_val=(lath_accs_new)*lath_accs_val
send_val=(intermediate_lath_wrks_val) + (intermediate_lath_accs_val)
array_email(k)=email
array_sendval(k)=send_val
k=k+1
rs.movenext
wend
rs.close
%>
<%
strsql2="update users set send='trim(send_val_arr)' where email='"& trim(email_arr) &"'"
for i=0 to k-1
send_val_arr=""
email_arr=""
'response.write(k)
response.write(array_email(i)) & vbcrlf
response.write(array_sendval(i)) & vbcrlf
send_val_arr=array_sendval(i)
email_arr=array_email(i)
objdc.execute(strsql2)
next
%>
<%
'if lath_wrks_val=1 then
%>
<form action="admin_ac_lath_wrks.asp" method="post">
<input type="hidden" name="lath_wrks_val" value="<% =lath_wrks_val %>" checked>
<input type="submit" value="Lathe Workholding" name="hello">
</form>
<%
'end if
%>
<%'
'if lath_accs_val=1 then
%>
<form action="admin_ac_lath_accs.asp" method="post">
<input type="hidden" name="lath_accs_val" value="<% =lath_accs_val %>" checked>
<input type="submit" value="Lathe Accs" name="hello">
</form>
<%
'end if
%>
</body>
</html>
The above code does not give me any errors but the database is not updated. To make sure the arrays are working I put in the response.write lines for printing out the array values and they work fine.
If however I use a constant for example
strsql2="update users set send=5"
instead of a variable :
strsql2="update users set send='trim(send_val_arr)' where email='"& trim(email_arr) &"'"
the database DOES get updated - all the values of the field "send" become 5.
What am I doing wrong??
Please help.
Thanks in advance
Al Kessop