below is some vb script that will let me view a database online, and let
me delete records from a webpage, it also sorts the columns.
the database is displayed correctly, but when i press on the delete link,
i get a server or scripting error. i can press back and then refresh and
the record is deleted. but this script is suppose to let me press delete
and then preform the action and refresh the page. this script is taken
directly from the example in iis5. i have it working there perfectly.
the only changes i made were to change strProvider to ConnectionString and
change some of the html. i have compared the 2 scripts over and over, i
think i need an expert to look this over. just ignore the comments about
the connection. thanks.
gratefully,
craig
<%
if request.form("sort")<> "" THEN
StrSort=request.form("sort")
ELSE
StrSort="TB1 ASC"
END IF
strQuery="SELECT * FROM SampleDb ORDER BY " &StrSort
'Database path statement for restricted viewing of the database.
ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data
Source=D:\64.227.68.95\infodb.mdb;User ID=;Password=;"
'This the model off of the iis5 server, DOES NOT WORK!!!
'strProvider="DRIVER={Microsoft Access Driver (*.mdb)}; DBQ=" &
Server.MapPath("http://64.227.68.95") & \infodb.mdb;"
'This is what i am getting from the host as the DSN-Less connection to
use,but, DOES NOT WORK!!!
'ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data
Source=D:\64.227.68.95\infodb.mdb;User ID=;Password=;"
'the DSN connection that works in another asp to the same database,but
here it DOES NOT WORK!!!
'set objConn = server.createobject("ADODB.Connection")
'objConn.Open "DSN=info"
'set cm = Server.CreateObject("ADODB.Command")
'cm.ActiveConnection = objConn
'Database path statement to allow visitors to view the database.
'strProvider="DRIVER=Microsoft Access Driver (*.mdb); DBQ=" &
Server.MapPath("iisadmin") & "\tour\sampledb.mdb;"
IF Request("ID") <> "" THEN
strIDNum=Request("ID")
set objConn = server.createobject("ADODB.Connection")
objConn.Open ConnectionString
set cm = Server.CreateObject("ADODB.Command")
cm.ActiveConnection = objConn
cm.CommandText = "DELETE FROM SampleDb WHERE ID = " &strIDNum
cm.Execute
END IF
Set rst = Server.CreateObject("ADODB.recordset")
rst.Open strQuery, ConnectionString
%>
<h1 align="center"> Online CopperTan Database </h1>
<form name=viewdb.asp action=viewdb.asp method=post>
<table border=1 cellspacing=3 cellpadding=3 rules=box>
<%
ON ERROR RESUME NEXT
IF rst.EOF THEN
Response.Write "There are no entries in the database."
ELSE%>
<tr>
<%
Response.Write "<td bgcolor='blue'><font
color='white'><center>DELETE RECORD</font></center></td>"
FOR i = 1 to rst.Fields.Count -1
Response.Write "<center><td width=200><input name=sort value=" &
rst(i).Name & " type=submit></td></center>"
NEXT
WHILE NOT rst.EOF %>
<tr>
<%
Response.Write "<td align=left valign=top
bgcolor='#ffffff'><a href=viewdb.asp?id=" & rst(0) & ">Delete</a></td>"
FOR i = 1 to rst.fields.count - 1
Response.Write "<td align=left valign=top
bgcolor='#ffffff'>" & rst(i) &"</td>"
NEXT
rst.MoveNext
WEND
END IF
%>