K
karenmiddleol
The following code works fine I can connect to a SQL database and list
all the records in the Orders table onto a web page.
Now our users want me to modify it so that each row displayed as a
button or a hyperlink for Modify, Delete and also they want the data
displayed not in a HTML table as I am doing but like in a form they
want the ability to change the data in the fields. So when the user
clicks on the modify button for a row then they want to capture what is
on the screen and update the database table.
Similarly, if they click the delete button or hyperlink on a row they
want it deleted.
Also, at the end of displaying all records in the table they want a
button or link to insert a new record.
Can you kindly let me know the changes to this code to accomplish this.
Thanks
Karen
<html>
<title>test</title>
<body>
<%
dim cn, rs, sql
dbname = "NorthWind"
Cn = "provider=SQLOLEDB;network=DBMSSOCN;"
Cn = Cn & "uid=sa;pwd=sa;server="
Cn = cn & "testserver;database=" & "NorthWind"
Set rs = Server.CreateObject("ADODB.Recordset")
sql = "select * from Orders"
rs.Open sql, cn
%>
<table BORDER="1" align="center" width="640">
<tr>
<td>OrderID</td>
<td>CustomerId</td>
<td>ShipName</td>
<td>ShipCity</td>
<td>ShipCountry</td>
</tr>
<%
' Move to the first record
rs.movefirst
' Start a loop that will end with the last record
do while not rs.eof
%>
<tr>
<td>
<%= rs("OrderId") %>
</td>
<td>
<%= rs("CustomerId") %>
</td>
<td>
<%= rs("ShipName") %>
</td>
<td>
<%= rs("ShipCity") %>
</td>
<td>
<%= rs("ShipCountry") %>
</td>
</tr>
<%
rs.movenext
loop %>
</table>
</body>
</html>
<%
rs.close
set rs=nothing
%>
all the records in the Orders table onto a web page.
Now our users want me to modify it so that each row displayed as a
button or a hyperlink for Modify, Delete and also they want the data
displayed not in a HTML table as I am doing but like in a form they
want the ability to change the data in the fields. So when the user
clicks on the modify button for a row then they want to capture what is
on the screen and update the database table.
Similarly, if they click the delete button or hyperlink on a row they
want it deleted.
Also, at the end of displaying all records in the table they want a
button or link to insert a new record.
Can you kindly let me know the changes to this code to accomplish this.
Thanks
Karen
<html>
<title>test</title>
<body>
<%
dim cn, rs, sql
dbname = "NorthWind"
Cn = "provider=SQLOLEDB;network=DBMSSOCN;"
Cn = Cn & "uid=sa;pwd=sa;server="
Cn = cn & "testserver;database=" & "NorthWind"
Set rs = Server.CreateObject("ADODB.Recordset")
sql = "select * from Orders"
rs.Open sql, cn
%>
<table BORDER="1" align="center" width="640">
<tr>
<td>OrderID</td>
<td>CustomerId</td>
<td>ShipName</td>
<td>ShipCity</td>
<td>ShipCountry</td>
</tr>
<%
' Move to the first record
rs.movefirst
' Start a loop that will end with the last record
do while not rs.eof
%>
<tr>
<td>
<%= rs("OrderId") %>
</td>
<td>
<%= rs("CustomerId") %>
</td>
<td>
<%= rs("ShipName") %>
</td>
<td>
<%= rs("ShipCity") %>
</td>
<td>
<%= rs("ShipCountry") %>
</td>
</tr>
<%
rs.movenext
loop %>
</table>
</body>
</html>
<%
rs.close
set rs=nothing
%>