•
•
•
•
What is DaniWeb IT Discussion Community?
You're currently browsing the ASP section within the Web Development category of DaniWeb, a massive community of 456,552 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 3,426 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our ASP advertiser: Lunarpages ASP Web Hosting
Views: 1728 | Replies: 3
![]() |
•
•
Join Date: Jan 2007
Posts: 10
Reputation:
Rep Power: 2
Solved Threads: 0
Have gotten the select statement and Update statement to work separatly, but need them to work on the same page and cannot seem to make it happen. Here is the current state of things. Any help would be appreciated.
asp Syntax (Toggle Plain Text)
<% Dim conn,rs,strsql,sql_update,ssn,cps strsql = "Select SSN From CWCT07 where SSN = '" & _ Request.Form("SSN") & "'" sql_update = "Update CWCT07 Set CPS = 'Yes' where ssn = '93737'" 'DSN less connection set conn = server.CreateObject("ADODB.Connection") set rs = server.CreateObject("ADODB.Recordset") Conn.Open "DRIVER={Microsoft Access Driver (*.mdb)};DBQ=d:\shared\Casework.mdb" rs.Open strsql conn.Execute sql_update If (not rs.BOF) and (not rs.EOF) then Response.Redirect "http://cwpsalem.pdx.edu/staff/Index.html" else Response.Redirect "http://cwpsalem.pdx.edu" end if 'close the connection rs.close set rs = nothing conn.close set conn = nothing %> </script>
•
•
Join Date: Jan 2007
Posts: 10
Reputation:
Rep Power: 2
Solved Threads: 0
•
•
•
•
try to update the record fter making rs=nothing
as may be when u open the recordset it is making it read only
for further assistance u can get back to me
RS was the problem. I was trying to include a redirect if no records were found and seemed to be doing it too late. I pulled out the If/Then and any references to RS here:
[code:ASP]
<%@ Language=VBScript %>
<%Response.Buffer=true%>
<HTML><HEAD>
<META NAME="GENERATOR" Content="Microsoft Visual Studio 6.0">
</HEAD>
<BODY>
<%
Dim conn,strsql,sql_update,ssn,cps
ssn = "Select SSN From CWCT07 where SSN = '" & Request.Form("SSN") & "'"
sql_update = "Update CWCT07 Set Jan25AM = 'Now()' where ssn = '" & Request.form("ssn") & "'"
'DSN less connection
set conn = server.CreateObject("ADODB.Connection")
'set rs = server.CreateObject("ADODB.Recordset")
Conn.Open "DRIVER={Microsoft Access Driver (*.mdb)};DBQ=d:\shared\Casework.mdb"
'rs.Open strsql
conn.Execute sql_update
'close the connection
conn.close
set conn = nothing
%>
</script>
Congratulations
</BODY></HTML>
[/code]
This works, except for the Time/date stamp, which I can address in another thread.
I would still like to include the If/then statement and am playing with different ways to make it happen. Mostly I get an "Object is invalid or closed" message when I try and include it then close the RS connection.
In response to Noman78's response to the previous post: It is not so much that I am new to ASP, but that I rarely (like once every two years or so) get a chance to use it in my job...then suddenly "can you do this?".:eek:
So I am trying to muddle through. Thanks for your help.
you can try this piece of code
set conn = server.CreateObject("ADODB.Connection")
set rs = server.CreateObject("ADODB.Recordset")
Conn.Open "DRIVER={Microsoft Access Driver (*.mdb)};DBQ=d:\shared\Casework.mdb"
rs.Open strsql
conn.Execute sql_update
dim eof_var ' a varriable
If (not rs.BOF) and (not rs.EOF) then
eof_var=1
else
eof_var=0
end if
'close the connection
rs.close
set rs = nothing
conn.close
set conn = nothing
If eof_var=1 then
Response.Redirect "http://cwpsalem.pdx.edu/staff/Index.html"
else
Response.Redirect "http://cwpsalem.pdx.edu"
end if
i hope it will work
set conn = server.CreateObject("ADODB.Connection")
set rs = server.CreateObject("ADODB.Recordset")
Conn.Open "DRIVER={Microsoft Access Driver (*.mdb)};DBQ=d:\shared\Casework.mdb"
rs.Open strsql
conn.Execute sql_update
dim eof_var ' a varriable
If (not rs.BOF) and (not rs.EOF) then
eof_var=1
else
eof_var=0
end if
'close the connection
rs.close
set rs = nothing
conn.close
set conn = nothing
If eof_var=1 then
Response.Redirect "http://cwpsalem.pdx.edu/staff/Index.html"
else
Response.Redirect "http://cwpsalem.pdx.edu"
end if
i hope it will work
![]() |
•
•
•
•
•
•
•
•
DaniWeb ASP Marketplace
•
•
•
•
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
- Motherboard Resources has no driver. Audio not working (Motherboards, CPUs and RAM)
- UPDATE query not working properly... (PHP)
- 6 working keys on laptop keyboard, rebooting... (Windows NT / 2000 / XP / 2003)
- Problem with Windows Update and WinXP (Web Browsers)
Other Threads in the ASP Forum
- Previous Thread: How can I send a Crystal Report to Email through Active Server Pages (ASP)?
- Next Thread: how to execute a url or hyperlink without leaving the existing page using asp


Linear Mode