Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > ASP General > How does one update all records displayed in a asp page

Reply
Thread Tools

How does one update all records displayed in a asp page

 
 
Jack
Guest
Posts: n/a
 
      01-25-2006
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.
 
Reply With Quote
 
 
 
 
Chi
Guest
Posts: n/a
 
      02-01-2006
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" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> 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.



 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Re: How include a large array? Edward A. Falk C Programming 1 04-04-2013 08:07 PM
Simple query returns 0 records in asp, but all records in vbscript masg0013@gmail.com ASP General 3 11-02-2006 09:23 AM
How to change data displayed in one GridView depending on selection made in the second one? (ASP.NET 2.0) misiek ASP .Net 7 02-28-2006 09:40 AM
any good idea about Update many records in one page, one batch Edward ASP .Net 1 06-10-2004 09:30 AM
Delete records or update records Dan ASP General 1 05-10-2004 01:25 PM



Advertisments