Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Invalid Argument

Status
Not open for further replies.

nivini

Programmer
Mar 24, 2004
64
0
0
I have a connection file
connection.asp
Code:
conStr="DRIVER=Microsoft Access Driver (*.mdb); DBQ="
DSNName=conStr & server.MapPath ("myMdb.mdb")
set con=server.createobject("adodb.connection")
con.open DSNName

and file display.asp which shows all records
Code:
<%@ language=vbScript codePage=1255 %>
<!--#Include File="connection.asp"-->
<%
shwReg="select * FROM tblNames"
set recReg=server.CreateObject ("adodb.recordset")
recReg.Open shwReg, con
recReg.MoveFirst 

%>
<html>
	<head>
		<script>
			function confirmDelete(delUrl) {
				if (confirm("Are you sure you want to delete this record?")) {
					document.location = delUrl;
				}
			}
		</script>
		<title>All players</title>
		
	</head>
	<body>
		<br>
		
		<table width="900" border="0" bgcolor="LightSteelBlue" cellspacing="1" align="center">
			<br>
			<tr class="DataGridHeader">
				<td bgcolor="#EBEBEB" background="Images/bgtr.gif">&nbsp;&nbsp;<a href="Display.asp?" class="DataGridHeader">Order</a></td>
				<td bgcolor="#EBEBEB" background="Images/bgtr.gif">&nbsp;&nbsp;<a href="Display.asp?" class="DataGridHeader">Type</a></td>
				<td bgcolor="#EBEBEB" background="Images/bgtr.gif">&nbsp;&nbsp;<a href="Display.asp?" class="DataGridHeader">Name</a></td>
				<td bgcolor="#EBEBEB" background="Images/bgtr.gif">&nbsp;&nbsp;<a href="Display.asp?" class="DataGridHeader">Department</a></td>
				<td bgcolor="#EBEBEB" background="Images/bgtr.gif">&nbsp;&nbsp;<a href="Display.asp?" class="DataGridHeader">Number</a></td>
				<td bgcolor="#EBEBEB" background="Images/bgtr.gif">&nbsp;&nbsp;<a href="Display.asp?" class="DataGridHeader">Email</a></td>
				<td bgcolor="#EBEBEB" background="Images/bgtr.gif">&nbsp;&nbsp;Options</td>
			</tr>
			<tr class="tablerowdata">
			<%
			while not recReg.EOF
			Response.Write "<tr class='tablerowdata'>" 
			Response.Write "<td bgcolor=#EBEBEB>" &recReg("RecordID") & " </td>" 
			Response.Write "<td bgcolor=#FAFAFA>" &recReg("typ1") & " </td>" 
			Response.Write "<td bgcolor=#EBEBEB>" &recReg("Nam1") & " </td>"
			Response.Write "<td bgcolor=#FAFAFA>" &recReg("Dep1") & " </td>"  
			Response.Write "<td bgcolor=#EBEBEB>" &recReg("Num1") & " </td>"
			Response.Write "<td bgcolor=#FAFAFA>" &recReg("Ema1") & " </td>"
			Response.Write "<td bgcolor=#EBEBEB><a href=javascript:confirmDelete('delRec.asp?Rec=" & recReg("RecordID") & "')>Delete</a></td>"
			recReg.MoveNext 
			Response.Write "</tr>"
			
			wend
			recReg.Close 
			con.Close
			%>
				
			<tr>
				<td colspan="7" background="Images/bgtr.gif"></td>
			</tr>
		</table>
		
			
		</div>
	</body>
</html>

and DelRec.asp file
Code:
<%@ language=vbScript codePage=1255 %>
<!--#Include File="connection.asp"-->
<%
recToDel=Request.QueryString("Rec") 

strSql="Delete from tblNames where RecordID=" & recToDel
set recReg1=server.CreateObject ("adodb.recordset")

set recReg1= con.Execute(strSql) 



'go back to the updated display
response.Redirect("display.asp")
%>
running it gives the list of records as display.asp should
clicking on delete gives the message for confirmation as should
BUT it ends with error "Invalid argument" in delRec.asp where the execute line runs.
WHAT is the problem with it, I ran these lines of code many times, it always worked what is wrong? can you see it??
Icant even delete a record when the strSql is:
Delete from tblNames where RecordID=1"
there is a record with recordID=1, I get the same error
please help.
 
So sorry falks
The mdb was corrupted , last thing I checked, sorry for your trouble
nivini
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top