charles
Posts: 59
|
| Posted: 02/28/2007, 9:00 PM |
|
Hi folks,
The following code is not updating the database as intended and is really stalling my project.
The code is intended to update a second table-departments- after a record form -delegations -submits data into another table called delegations.
Below is the custom code
dim delegates
Dim SQL
Dim Connection
Dim ErrorMessage
Set Connection = New clsDBConnection1
Connection.Open
delegates=Request.form("delegate_to")
SQL = "update departments" &_
"<br>set depman_id = " & delegations.delegate_to.value &_
"<br>where depman_id = "& delegations.depman_id.value
Connection.Execute(SQL)
ErrorMessage = CCProcessError(Connection)
Connection.Close
Set Connection = Nothing
On Error Goto 0
As i have been thought in this forum,i added the following lines of code after the SQL statement
response.write"SQL= "& SQL & "<br>" & "delegates=" & delegates
response.end
After submiting the form, the following lines are written to the screen
SQL= update departments
set depman_id = 449
where depman_id = 446
delegates=449
This seems to suggest that the code is working properly, but the second table is not being updated all the same.
Am at my wit's end, and needs to turn this project over like yesterday.I will really appreciate if someone can help.
Regards,
Charles
|
 |
 |
Benjamin Krajmalnik
|
| Posted: 03/01/2007, 7:23 AM |
|
A few things.
First of all, do things the "CodeCharge" way,
Instead of "Request.Form", use delegations.delegate_to.value, or even better
(depending on your embed, which you did not mention)
EventCaller.delegate_to.value.
Second of all, you SQL is not valid SQL.
I don't know what thiose "<br>"'s are doing in there - that is HTML code.
SQL = "update departments" &_
" set depman_id = " & delegations.delegate_to.value &_
" where depman_id = "& delegations.depman_id.value
Note the spaces after the initial double quote on the 2nd and 3rd lines.
The <br>'s were killing you.
"charles" <charles@forum.codecharge> wrote in message
news:645e65dd5aad18@news.codecharge.com...
> Hi folks,
> The following code is not updating the database as intended and is really
> stalling my project.
> The code is intended to update a second table-departments- after a record
> form
> -delegations -submits data into another table called delegations.
> Below is the custom code
>
> dim delegates
> Dim SQL
> Dim Connection
> Dim ErrorMessage
> Set Connection = New clsDBConnection1
> Connection.Open
> delegates=Request.form("delegate_to")
> SQL = "update departments" &_
> "<br>set depman_id = " & delegations.delegate_to.value &_
> "<br>where depman_id = "& delegations.depman_id.value
> Connection.Execute(SQL)
> ErrorMessage = CCProcessError(Connection)
> Connection.Close
> Set Connection = Nothing
> On Error Goto 0
>
> As i have been thought in this forum,i added the following lines of code
> after
> the SQL statement
> response.write"SQL= "& SQL & "<br>" & "delegates=" & delegates
> response.end
> After submiting the form, the following lines are written to the screen
>
> SQL= update departments
> set depman_id = 449
> where depman_id = 446
> delegates=449
> This seems to suggest that the code is working properly, but the second
> table
> is not being updated all the same.
> Am at my wit's end, and needs to turn this project over like yesterday.I
> will
> really appreciate if someone can help.
> Regards,
> Charles
>
>
>
>
> ---------------------------------------
> Sent from YesSoftware forum
> http://forums.codecharge.com/
>
|
|
|
 |
charles
Posts: 59
|
| Posted: 03/01/2007, 1:51 PM |
|
Thank you benjamin for your quick response.
I adjusted the code as you suggested but still the department table was not being updated.
The response.write displays this on the screen
SQL= update departments set depman_id = 448 where depman_id = 446
This would seem to suggest that the sql is ok but why is the database not being updated?
Could it be that the event is not executing? how can i test if the event is executing?
When i ran the SQL on SQL server query analyser it updates the department table alright.
This is the new adjusted code
Dim SQL
Dim Connection
Dim ErrorMessage
Set Connection = New clsDBConnection1
Connection.Open
SQL = "update departments" &_
" set depman_id = " & delegations.delegate_to.value &_
" where depman_id = "& delegations.depman_id.value
response.write"SQL= "& SQL
response.end
Connection.Execute(SQL)
ErrorMessage = CCProcessError(Connection)
Connection.Close
Set Connection = Nothing
On Error Goto 0
So where can this issue be coming from and what can i do?
Regards,
Charles
|
 |
 |
Benjamin Krajmalnik
|
| Posted: 03/04/2007, 10:43 AM |
|
which event are you using?
which database backend are you using?
"charles" <charles@forum.codecharge> wrote in message
news:645e74ae0951fe@news.codecharge.com...
> Thank you benjamin for your quick response.
> I adjusted the code as you suggested but still the department table was
> not
> being updated.
> The response.write displays this on the screen
>
> SQL= update departments set depman_id = 448 where depman_id = 446
>
> This would seem to suggest that the sql is ok but why is the database not
> being
> updated?
> Could it be that the event is not executing? how can i test if the event
> is
> executing?
> When i ran the SQL on SQL server query analyser it updates the department
> table alright.
> This is the new adjusted code
> Dim SQL
> Dim Connection
> Dim ErrorMessage
> Set Connection = New clsDBConnection1
> Connection.Open
> SQL = "update departments" &_
> " set depman_id = " & delegations.delegate_to.value &_
> " where depman_id = "& delegations.depman_id.value
>
> response.write"SQL= "& SQL
> response.end
> Connection.Execute(SQL)
> ErrorMessage = CCProcessError(Connection)
> Connection.Close
> Set Connection = Nothing
> On Error Goto 0
>
>
> So where can this issue be coming from and what can i do?
> Regards,
> Charles
>
> ---------------------------------------
> Sent from YesSoftware forum
> http://forums.codecharge.com/
>
|
|
|
 |
hiraldesai
Posts: 38
|
| Posted: 03/06/2007, 4:24 AM |
|
You have got "response.end" before "connection.execute(sql)" statement !!? This will terminate the script execution before the execution of the SQL statement.
Quote charles:
Thank you benjamin for your quick response.
I adjusted the code as you suggested but still the department table was not being updated.
The response.write displays this on the screen
SQL= update departments set depman_id = 448 where depman_id = 446
This would seem to suggest that the sql is ok but why is the database not being updated?
Could it be that the event is not executing? how can i test if the event is executing?
When i ran the SQL on SQL server query analyser it updates the department table alright.
This is the new adjusted code
Dim SQL
Dim Connection
Dim ErrorMessage
Set Connection = New clsDBConnection1
Connection.Open
SQL = "update departments" &_
" set depman_id = " & delegations.delegate_to.value &_
" where depman_id = "& delegations.depman_id.value
response.write"SQL= "& SQL
response.end
Connection.Execute(SQL)
ErrorMessage = CCProcessError(Connection)
Connection.Close
Set Connection = Nothing
On Error Goto 0
So where can this issue be coming from and what can i do?
Regards,
Charles
_________________
-------
Hiral |
 |
 |
charles
Posts: 59
|
| Posted: 03/09/2007, 10:43 AM |
|
Thanks hiral for the observation.
The moment i adjusted the code it starts working as intended.
Thank you so much!
regards,
charles
|
 |
 |
|