 |
| Classic ASP Databases Discuss using ASP 3 to work with data in databases, including ASP Database Setup issues from the old P2P forum on this specific subtopic. See also the book forum Beginning ASP.NET Databases for questions specific to that book. NOT for ASP.NET 1.0, 1.1, or 2.0. |
Welcome to the p2p.wrox.com Forums.
You are currently viewing the Classic ASP Databases section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
|
|
|
|

October 25th, 2004, 08:09 AM
|
|
Authorized User
|
|
Join Date: Oct 2004
Posts: 19
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
No updates is done.
All my code is in the first topic. The next code is Case "Ta bort rad"
|
|

October 25th, 2004, 08:18 AM
|
|
Friend of Wrox
|
|
Join Date: Jun 2003
Posts: 2,480
Thanks: 0
Thanked 1 Time in 1 Post
|
|
hmmm... I am left with no clue on what you are missing there.
_________________________
- Vijay G
Strive for Perfection
|
|

October 25th, 2004, 08:28 AM
|
|
Authorized User
|
|
Join Date: Oct 2004
Posts: 19
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
I was a little to quick there.
Nothing gets updated in database and on the page the old value
is still there.
when I do the Response.Write the values before update and after I get this result.
Before update - -- // the variables have no value
After update - xxxxx -- yyyyy // This shows the value that I put
in the input box.
Before update - xxxxx -- yyyyy // Now the values is put in once again
After update - -- // no values. All this is for the first record
It´s difficult to explain what I meen. Hope you understand
/Cilla
|
|

October 25th, 2004, 08:46 AM
|
|
Friend of Wrox
|
|
Join Date: Jun 2003
Posts: 2,480
Thanks: 0
Thanked 1 Time in 1 Post
|
|
Sorry, unless I see the code that you have written in that particular case, I am unable to comment on what is going wrong there, as you have given me two types of out put in two different posts. Is that difficult to post that part of code here?
Cheers!
_________________________
- Vijay G
Strive for Perfection
|
|

October 26th, 2004, 01:02 AM
|
|
Authorized User
|
|
Join Date: Oct 2004
Posts: 19
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
I still think the problem is theses variables. I wont to take out a record, but it´s seem that I do it Twice. vCUSTOMERNAMEn and vUSER_IDn is counters, maybe I should only have one counter. I tied that to, but I don´t get it to work.
This is just the countervariables.
vCUSTOMERNAMEn= "CUSTOMERNAME" & myRs.Fields("CUID")
vCUSTOMERNAME=request.form(vCUSTOMERNAMEn)
vUSER_IDn="USER_ID" & myRs.Fields("CUID")
vUSER_ID=request.form(vUSER_IDn)
myRs.Fields("CUSTOMERNAME")= vCUSTOMERNAME
myRs.Fields("USER_ID")=vUSER_ID
Here is the Case "Uppdatera" where my update is, and the Case "Ta bort rad" is the next code.
Code:
Case "Uppdatera"
Set myConn = Server.CreateObject("ADODB.Connection")
myConn.Open "DSN=CPRCT;UID=" & session("anvid") & ";PWD=" & session("password") & ""
Set myRs = Server.CreateObject("ADODB.Recordset")
SQL = "SELECT * FROM TEST.Customer"
myRS.Open SQL,myConn,3,4
Do Until myRs.EOF
Response.Write "Före update - " & vCUSTOMERNAME & "--" & vUSER_ID & "<br>"
vCUSTOMERNAMEn= "CUSTOMERNAME" & myRs.Fields("CUID")
vCUSTOMERNAME=request.form(vCUSTOMERNAMEn)
vUSER_IDn="USER_ID" & myRs.Fields("CUID")
vUSER_ID=request.form(vUSER_IDn)
myRs.Fields("CUSTOMERNAME")= vCUSTOMERNAME
myRs.Fields("USER_ID")=vUSER_ID
myRs.Update
Response.Write "Efter update - " & myRs.Fields("CUSTOMERNAME") & "--" & myRs.Fields("USER_ID") & "<br>"
myRs.MoveNext
Loop
'myRs.Requery
myRs.Close
myRs.Open SQL,myConn,3,4
%>
<Form Method=Post Action="Customer.asp"><Table><TR><TD><B>Kundid</B></TD><TD><B>Kundnamn</B></TD><TD><B>Användarid</B></TD><TD><B>Ta bort?</B></TD></TR>
<%
Do While not myRs.EOF
%>
<TR><TD><INPUT TYPE="text" name="CUID<%=myRs.Fields("CUID") %>" value="<%= myRs.Fields("CUID") %>"></TD>
<TD><INPUT TYPE="text" name="CUSTOMERNAME<%=myRs.Fields("CUID") %>" value ="<%= myRs.Fields("CUSTOMERNAME") %>"></TD>
<TD><INPUT TYPE="text" name="USER_ID<%=myRs.Fields("CUID") %>" value = "<%= myRs.Fields("USER_ID") %>"></B></TD>
<TD><INPUT TYPE="checkbox" name="chkbx<%=myRs.Fields("CUID") %>"></TD></TR>
<%
myRs.MoveNext
Loop
%>
<TR><TD COLSPAN=3><INPUT TYPE="submit" name="btnval" value="Uppdatera">
<INPUT TYPE="submit" name="btnval" value="Ta bort rad"></TD></TR></Form></Table>
<%
Set myRs = Nothing
Set myConn = Nothing
Case "Ta bort rad"
Set myConn = Server.CreateObject("ADODB.Connection")
myConn.Open "DSN=CPRCT;UID=" & session("anvid") & ";PWD=" & session("password") & ""
Set myRs = Server.CreateObject("ADODB.Recordset")
SQL = "SELECT * FROM TEST.PRODUCT"
myRS.Open SQL,myConn,3,4
For Each collitem in Request.Form
If Left(collitem, 5) = "chkbx" Then
vRecordToDelete = Mid(collitem, 6, 10)
myRs.Find "CUID = " & vRecordToDelete & ""
If myRs.BOF Then
Response.Write "Raden " & vRecordToDelete & " hittades ej.<BR>"
Else
If myRs.EOF Then
Response.Write "Raden " & vRecordToDelete & " hittades ej.<BR>"
Else
myRs.Delete
Response.Write "Raden " & vRecordToDelete & " togs bort.<BR>"
End If
End If
End If
Next
myRs.Requery
%>
<Form Method=Post Action="Customer.asp"><Table><TR><TD><B>Kundid</B></TD><TD><B>Kundnamn</B></TD><TD><B>Användarid</B></TD><TD><B>Ta bort?</B></TD></TR>
<%
Do While not myRs.EOF
%>
<TR>
<TD><INPUT TYPE="text" name="CUID<%=myRs.Fields("CUID") %>" value="<%=myRs.Fields("CUID") %>"></TD>
<TD><INPUT TYPE="text" name="CUSTOMERNAME<%=myRs.Fields("CUID") %>" value ="<%=myRs.Fields("CUSTOMERNAME") %>"></TD>
<TD><INPUT TYPE="text" name="USER_ID<%=myRs.Fields("CUID") %>" value = "<%=myRs.Fields("USER_ID") %>"></TD>
<TD><INPUT TYPE="checkbox" name="chkbx<%=myRs.Fields("CUID") %>"></TD></TR>
<%
myRs.MoveNext
Loop
%>
<TR><TD COLSPAN=3><INPUT TYPE="submit" name="btnval" value="Uppdatera">
<INPUT TYPE="submit" name="btnval" value="Ta bort rad"></TD></TR></Form></Table>
<%
Set myRs = Nothing
Set myConn = Nothing
End Select
%>
|
|

October 26th, 2004, 02:05 AM
|
|
Friend of Wrox
|
|
Join Date: Jun 2003
Posts: 2,480
Thanks: 0
Thanked 1 Time in 1 Post
|
|
You have used the first response.write statement on the wrong place. That's why you were not seeing data before update.
Code:
' comment the line below
Response.Write "Före update - " & vCUSTOMERNAME & "--" & vUSER_ID & "<br>"
vCUSTOMERNAMEn= "CUSTOMERNAME" & myRs.Fields("CUID")
vCUSTOMERNAME=request.form(vCUSTOMERNAMEn)
vUSER_IDn="USER_ID" & myRs.Fields("CUID")
vUSER_ID=request.form(vUSER_IDn)
' should come here...
Response.Write "Före update - " & vCUSTOMERNAME & "--" & vUSER_ID & "<br>"
myRs.Fields("CUSTOMERNAME")= vCUSTOMERNAME
myRs.Fields("USER_ID")=vUSER_ID
myRs.Update
Response.Write "Efter update - " & myRs.Fields("CUSTOMERNAME") & "--" & myRs.Fields("USER_ID") & "<br>"
_________________________
- Vijay G
Strive for Perfection
|
|

October 26th, 2004, 03:07 AM
|
|
Authorized User
|
|
Join Date: Oct 2004
Posts: 19
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
Yes, thank you. Now the variables looks fine when I write them out, they contents the correct values, but no update is done. If I click one more time to the submit buttom, The old values is back again.
|
|

October 26th, 2004, 04:16 AM
|
|
Friend of Wrox
|
|
Join Date: Jun 2003
Posts: 2,480
Thanks: 0
Thanked 1 Time in 1 Post
|
|
Hi there,
This code works perfect for me. I am able to update without any problems. Only change from that of yours is, I changed the locktype parameter to RECORDSET.OPEN method.
<%
Set myConn = Server.CreateObject("ADODB.Connection")
myConn.Open "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & server.mappath("mydb.mdb") & ";User Id=admin;Password=;"
Set myRs = Server.CreateObject("ADODB.Recordset")
SQL = "SELECT * FROM table1"
myRS.Open SQL,myConn,3,3
If len(Request.form("btnval")) > 0 then
While not myRs.EOF
vCUSTOMERNAMEn= "CUSTOMERNAME" & myRs.Fields("CUID")
vCUSTOMERNAME=request.form(vCUSTOMERNAMEn)
vUSER_IDn="USER_ID" & myRs.Fields("CUID")
vUSER_ID=request.form(vUSER_IDn)
Response.Write "Före update - " & vCUSTOMERNAME & "--" & vUSER_ID & "<br>"
myRs.Fields("CUSTOMERNAME")= vCUSTOMERNAME
myRs.Fields("USER_ID")=vUSER_ID
myRs.Update
Response.Write "Efter update - " & myRs.Fields("CUSTOMERNAME") & "--" & myRs.Fields("USER_ID") & "<br>"
myRs.MoveNext
Wend
End If
myRs.Requery
%>
<Form Method="Post" Action="Updaterec.asp"><Table><TR><TD><B>Kundid</B></TD><TD><B>Kundnamn</B></TD><TD><B>Användarid</B></TD><TD><B>Ta bort?</B></TD></TR>
<%
While not myRs.EOF
%>
<TR><TD><INPUT TYPE="text" name="CUID<%=myRs.Fields("CUID") %>" value="<%= myRs.Fields("CUID") %>"></TD>
<TD><INPUT TYPE="text" name="CUSTOMERNAME<%=myRs.Fields("CUID") %>" value ="<%= myRs.Fields("CUSTOMERNAME") %>"></TD>
<TD><INPUT TYPE="text" name="USER_ID<%=myRs.Fields("CUID") %>" value = "<%= myRs.Fields("USER_ID") %>"></B></TD>
<%
myRs.MoveNext
Wend
%>
<TR><TD COLSPAN=3><INPUT TYPE="submit" name="btnval" value="Uppdatera">
</TD></TR></Form></Table>
<%
Set myRs = Nothing
Set myConn = Nothing
%>
Try this code alone on a separate page, and change the connection string and the sql statement to that of yours.
Hope that helps.
Cheers!
_________________________
- Vijay G
Strive for Perfection
|
|

October 26th, 2004, 05:35 AM
|
|
Authorized User
|
|
Join Date: Oct 2004
Posts: 19
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
Thank you, Now I changed my code, And I finnaly get a Error message.
Microsoft OLE DB Provider for ODBC Drivers (0x80004005)
[IBM][CLI Driver] CLI0150E Driver not capable. SQLSTATE=S1C00
Permission problem I guess.
But I have given the IUSER_xxx execute script permission in the web folder and made IUSER_xxx, a User in my DB2 database.
IUSER_xxx has also got SELECT,INSERT,UPDATE AND DELETE permissions on all object´s in the database.
Do I have to do moore than that?
|
|

October 26th, 2004, 06:05 AM
|
|
Friend of Wrox
|
|
Join Date: Jun 2003
Posts: 2,480
Thanks: 0
Thanked 1 Time in 1 Post
|
|
I am not sure if you have used up my connection string that was posted here. The only change you should have tried is the LOCK parameter of Recordset.Open method. Looks like you have made all those mentioned in RED in my earlier post.
Cheers!
_________________________
- Vijay G
Strive for Perfection
|
|
 |