473,387 Members | 1,532 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

How to add a button to Modify, delete or add a new record to this code

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
%>

Oct 1 '05 #1
2 2068
Hi Karen,

I take it from your code you are using ASP not ASP.NET?

Let me know and I will try to come up with some suggestions.

"ka***********@yahoo.com" wrote:
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
%>

Oct 4 '05 #2
Hi Helen

I am working on ASP.

If I was using ASP.Net I would have used one of the number of options.

Please help if you can for classic ASP.

Thanks
Karen

Oct 4 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Franco Fellico' | last post by:
Hi. Suppose to have read and displayed (using PHP) a group of row of a DB table on a dinamyc table on a HTML/PHP page. The number of row displayed could be from 1 to n. Each row contains...
5
by: brian4cards | last post by:
http://www.igearonline.com/subscribe/admin.asp I have an html table that is loaded with database records. I have edit and delete options inside the table that edit or delete a given row. They...
0
by: karenmiddleol | last post by:
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...
2
by: uv | last post by:
Hi! I'm having problems submitting a new record through the form. I'm working with the wizard and I've added a control button to my form for entering entering a new record but for some reason it...
3
by: NateDawg | last post by:
I'm reposting this. I'm kinda in a bind untill i get this figured out, so if anyone has some input it would sure help me out. Ok, I’ve noticed a few gridview problems floating around the forum....
14
by: Kevin | last post by:
A couple of easy questions here hopefully. I've been working on two different database projects which make use of multiple forms. 1. Where's the best/recommended placement for command buttons...
1
by: Bill_W_Stephens | last post by:
I need a form with two buttons and ability to detect which button was pressed. I got this code to work using a javascript global variable, but I know there must be a better way using DOM. Any...
2
by: AA Arens | last post by:
When I add a button and choose in the wizzard for Delete Record operation, it does not work, instead it ADD's a record? How come? This is the VB contents of the button: Private Sub...
3
by: bluez | last post by:
I want to design a webpage where user can search the data from the database and list out the related records. Each of the record got a delete button which allow user to delete the record. ...
7
by: ITAutobot25 | last post by:
My delete button is not working in my GUI and my due date is today before midnight. Can anyone show me how to correct this error? My assignment statement is below as well as 5 classes. InventoryGUI...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.