Good morning every one,
I want to delete records in my database by using connectingString e.g write id=6
to delete instead of this code
<%
set conn=Server.CreateObject("ADODB.Connection")
conn.Provider="Microsoft.Jet.OLEDB.4.0"
conn.Open"C:\Inetpub\wwwroot\template\database\database1.mdb"
pid=Request.Form("PatientId")
if Request.form("Patientname")="" then
Set rs = Server.CreateObject("ADODB.Recordset")
rs.open "SELECT * FROM Patient WHERE PatientId=" & pid,conn
%>
<form method="post" action="demo_delete.asp">
<table>
<%for each x in rs.Fields%>
<tr>
<td><%=x.name%></td>
<td><input name="<%=x.name%>" value="<%=x.value%>"></td>
<%next%>
</tr>
</table>
<input type="submit" value="Delete record">
</form>
<%
else
sql="DELETE FROM Patient"
sql=sql & " WHERE PatientId=" & pid
on error resume next
conn.Execute sql
if err<>0 then
response.write("No update permissions!")
else
response.write("Record " & pid & " was deleted!")
end if
end if
conn.close
%>
<%
Dim adoCon
Dim rs
Dim strSQL
Dim lngRecordNo
'Read in the record number to be deleted
lngRecordNo = CLng(Request.QueryString("id"))
Set adoCon = Server.CreateObject("ADODB.Connection")
adoCon.Open "Provider=Microsoft.Jet.OLEDB.4.0; Data Source=" & Server.MapPath("C:\Inetpub\wwwroot\template\database\database1.mdb")
Set rs = Server.CreateObject("ADODB.Recordset")
strSQL = "SELECT Patient.* FROM Patient WHERE Patient.PatientId=" & lngRecordNo
Response.write strSQL
rs.LockType = 3
rs.Open strSQL, adoCon
if rs.EOF then
Response.Write("<h3> please Enter a Vaild Number</h3>")
Else
%>
<html>
<title><h2>Delete Form </h2></title>
<body bgcolor="white" text="black">
<form name="form" method="post" action="demo_delete.asp">
<table>
<td>Patient Name:</td>
<td><input name="name" value="<% =rs("Patientname") %>"></td>
</tr><tr>
<td>Sex :</td>
<td><input name="sex" value="<% =rs("Sex") %>"></td>
</tr><tr>
<td>phone :</td>
<td><input name="phone" value="<% =rs("phone") %>"></td>
</tr><tr>
<td>Date:</td>
<td><input name="Date" value="<% =rs("Datee") %>"></td>
</tr>
</table>
<input type="hidden" name="ID_no" value="<% = lngRecordNo%>">
<input type="submit" name="Submit" value="Delete">
</form>
<p>
<p>
<a href="delete_select.asp" title="Back To Delete Page">Back To Delete Page</a>
</body>
</html>
<%
End IF
rs.Close
adoCon.Close
Set rs = Nothing
Set adoCon = Nothing
%>
<html>
<body>
<h2>Delete Record</h2>
<% 'Dimension variables
Dim adoCon 'Holds the Database Connection Object
Dim rs 'Holds the recordset for the record to be deleted
Dim strSQL 'Holds the SQL query to query the database
Dim lngRecordNo 'Holds the record number to be deleted
'Read in the record number to be deleted
lngRecordNo = Request.form ("ID_no")
'Create an ADO connection object
Set adoCon = Server.CreateObject("ADODB.Connection")
'Set an active connection to the Connection object using a DSN-less connection
adoCon.Open "Provider=Microsoft.Jet.OLEDB.4.0; Data Source=" & Server.MapPath("C:\Inetpub\wwwroot\template\database\database1.mdb")
Set rs = Server.CreateObject("ADODB.Recordset")
strSQL = "Delete * FROM Patient WHERE PatientId="&lngRecordNo
rs.Open strSQL, adoCon
Response.Write"<center><h2>patient was delete/<h2></center>"
adoCon.Close
Set rs = Nothing
Set adoCon = Nothing
Response.Redirect "delete_select.asp"
%>
</body>
</html>