By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
429,077 Members | 2,160 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 429,077 IT Pros & Developers. It's quick & easy.

How does one update all records displayed in a asp page

P: n/a
Hi,
I got a test asp page which connects to Northwind.mdb database. This page
pulls all the rows from the Customers table. One column i.e. GoodStatus has
been added to the customers table. The following is the code to display all
records of the customers table with some customization.
CODE:
<%@ Language=VBScript %>
<!-- #include file="adovbs.inc" -->
<HTML>
<BODY>

<META NAME="GENERATOR" Content="Microsoft Visual Studio 6.0">
<title>Testing Multiple Records Save</title>

<SCRIPT LANGUAGE="VBScript">
sub btn_LogOut_OnClick()
dim asnwer
answer=msgbox("Are you sure you want to exit?.",vbYesNo,"Warning")
if answer=vbyes then
window.location.href = "http://localhost/beginaspdatabase1/"
end if
end sub

sub btn_Save_OnClick()
dim asnwer
answer=msgbox("Are you sure you want to save your
changes?",vbYesNo,"Warning")
if answer=vbyes then
window.location.href =
"http://localhost/beginaspdatabase1/update_all_records.asp"
end if
end sub
</SCRIPT>
</HEAD>

<%
myDSN="Provider=Microsoft.Jet.OLEDB.4.0;" & _
"Data Source=C:\Northwind97\Northwind.mdb"

set CN=server.createobject("ADODB.Connection")
CN.Open myDSN

set sRS=server.createobject("ADODB.Recordset")

sRS.ActiveConnection = CN

SQL = "SELECT EmployeeID, LastName, FirstName, Title, GoodStatus from
Employees"
'Response.Write SQL & "<br>"
'Response.End
sRS.Open SQL

%>
<div ALIGN="CENTER">
<big><big><font COLOR="navy">Test Database Northwind</font></big></big>

<H4>
<font COLOR="red">Saving changes of all records at one time</font>
</H4>
</div>
<div ALIGN="CENTER">
<%
Response.Write "<table border='1' width='50%' height='1' cellspacing='1' >"
Response.Write "<th>ID</th><th>Last Name</th><th>First
Name</th><th>Title</th><th>Good Status</th>"
%>
<%
do until sRS.eof
ID = sRS("EmployeeID")
LastName = sRS("LastName")
FirstName = sRS("FirstName")
Title = sRS("Title")
l_GoodStatus = sRS("GoodStatus")
%>

<tr>
<td align='center' width = '5%'>
<font color="#000000">
<%Response.Write ID%></font>
</td>
<td align='center' width = '12%'>
<font color="#000000">
<%Response.Write LastName%>

<td align='center' width = '12%' >
<font color="#000000">
<%Response.Write FirstName%>

<td align='center' width = '10%'>
<font color="#000000">
<input type="text" name="txt_Title" size="33" value ="<%Response.Write
(Title)%>" style="font-family: Times New Roman; font-size: 10pt"></font>
</td>
<%'Response.Write Title%>
</td>

<td align='center' width = '8%'>
<font color="#000000">
<input type="checkbox" name="chk_GoodStatus" value="ON" <%Response.write
l_GoodStatus%><%if cbool(l_GoodStatus) then response.write " checked" else
Response.write " unchecked"%>>
</td>
</tr>

<%
sRs.MoveNext
loop
sRS.Close
Set sRS = Nothing
%>

</DIV>

<input type="button" value="Log Out" name="btn_LogOut" >
<input type="submit" value="Save" name="btn_Save">

</BODY>
</HTML>

Now I need to change some values in the title and goodstatus field and save
all the changes in whatever records made. This update has to be in asp page
update_all_records.asp as pointed in the code above. I have no idea how to
handle all the rows as in the present case. Any help or suggestion is
appreciated. Thanks.
Jan 25 '06 #1
Share this Question
Share on Google+
1 Reply


P: n/a
Chi
Best bet is...
1. Pass all the values in a form to SqlParameters (one value to one
parameter)
2. Then Create a stored procedure that uses these parameters.
then you can update, insert, whatever it is you want to do.
"Jack" <Ja**@discussions.microsoft.com> wrote in message
news:45**********************************@microsof t.com...
Hi,
I got a test asp page which connects to Northwind.mdb database. This page
pulls all the rows from the Customers table. One column i.e. GoodStatus
has
been added to the customers table. The following is the code to display
all
records of the customers table with some customization.
CODE:
<%@ Language=VBScript %>
<!-- #include file="adovbs.inc" -->
<HTML>
<BODY>

<META NAME="GENERATOR" Content="Microsoft Visual Studio 6.0">
<title>Testing Multiple Records Save</title>

<SCRIPT LANGUAGE="VBScript">
sub btn_LogOut_OnClick()
dim asnwer
answer=msgbox("Are you sure you want to exit?.",vbYesNo,"Warning")
if answer=vbyes then
window.location.href = "http://localhost/beginaspdatabase1/"
end if
end sub

sub btn_Save_OnClick()
dim asnwer
answer=msgbox("Are you sure you want to save your
changes?",vbYesNo,"Warning")
if answer=vbyes then
window.location.href =
"http://localhost/beginaspdatabase1/update_all_records.asp"
end if
end sub
</SCRIPT>
</HEAD>

<%
myDSN="Provider=Microsoft.Jet.OLEDB.4.0;" & _
"Data Source=C:\Northwind97\Northwind.mdb"

set CN=server.createobject("ADODB.Connection")
CN.Open myDSN

set sRS=server.createobject("ADODB.Recordset")

sRS.ActiveConnection = CN

SQL = "SELECT EmployeeID, LastName, FirstName, Title, GoodStatus from
Employees"
'Response.Write SQL & "<br>"
'Response.End
sRS.Open SQL

%>
<div ALIGN="CENTER">
<big><big><font COLOR="navy">Test Database Northwind</font></big></big>

<H4>
<font COLOR="red">Saving changes of all records at one time</font>
</H4>
</div>
<div ALIGN="CENTER">
<%
Response.Write "<table border='1' width='50%' height='1' cellspacing='1'
>"

Response.Write "<th>ID</th><th>Last Name</th><th>First
Name</th><th>Title</th><th>Good Status</th>"
%>
<%
do until sRS.eof
ID = sRS("EmployeeID")
LastName = sRS("LastName")
FirstName = sRS("FirstName")
Title = sRS("Title")
l_GoodStatus = sRS("GoodStatus")
%>

<tr>
<td align='center' width = '5%'>
<font color="#000000">
<%Response.Write ID%></font>
</td>
<td align='center' width = '12%'>
<font color="#000000">
<%Response.Write LastName%>

<td align='center' width = '12%' >
<font color="#000000">
<%Response.Write FirstName%>

<td align='center' width = '10%'>
<font color="#000000">
<input type="text" name="txt_Title" size="33" value ="<%Response.Write
(Title)%>" style="font-family: Times New Roman; font-size: 10pt"></font>
</td>
<%'Response.Write Title%>
</td>

<td align='center' width = '8%'>
<font color="#000000">
<input type="checkbox" name="chk_GoodStatus" value="ON" <%Response.write
l_GoodStatus%><%if cbool(l_GoodStatus) then response.write " checked" else
Response.write " unchecked"%>>
</td>
</tr>

<%
sRs.MoveNext
loop
sRS.Close
Set sRS = Nothing
%>

</DIV>

<input type="button" value="Log Out" name="btn_LogOut" >
<input type="submit" value="Save" name="btn_Save">

</BODY>
</HTML>

Now I need to change some values in the title and goodstatus field and
save
all the changes in whatever records made. This update has to be in asp
page
update_all_records.asp as pointed in the code above. I have no idea how to
handle all the rows as in the present case. Any help or suggestion is
appreciated. Thanks.

Feb 1 '06 #2

This discussion thread is closed

Replies have been disabled for this discussion.