Results 1 to 3 of 3

Thread: ASP Newbie - Keep Getting This Stupid Error - ARRRRRRR

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    Aug 2000
    Location
    Australia
    Posts
    149
    Hi,
    I am a little new to ASP (I have made some stuff that works).
    I am having this problem with a script where I want to add just some fields from an online form to a database. It is very simple,

    The error that I keep getting is

    [Microsoft][ODBC Microsoft Access Driver] Two Few parameters. Expected 4.

    Line 173
    I will post the code so that you can have a look at it and I have marked line 173 where the error is.

    Any help would be much appreciated.

    Code:
    <html>
    <head>
    <title>Add To Lan Reg Database1</title>
    </head>
    <body bgcolor="black" text="#C5BE60" topmargin=0 leftmargin=0>
    <center>
    <%
    Flag = request.form("Flag")
    If IsEmpty(Flag) or Flag = "" then
    %>
    <font face="times new roman">
    <i><h1>ADD TO LAN REG</h1></i>
    	<font face="arial" size=2>
    	 <b><i>Note:</i> * indicates a required field</b>
    	</font>
    
    </font>
    <p> 
    <table width=500 border=0>
      <tr>
        <td width=100>
        <font face="arial" size=2>
    	<b>*First Name:</b>
    	</font>
    	</td>
    
    	<td width=400>
    	<form action="add1.asp" method="post">
    	<input type="text" name="FirstName" size=20>
    	</td>
      </tr>
      
      <tr>
        <td width=100>
        <font face="arial" size=2>
    	<b>*Last Name:</b> 
        </font>
    	</td>
    	
    	<td width=400><input type="text" name="LastName" size=20></td>
      </tr>
      
      <tr>
        <td width=100>
        <font face="arial" size=2>
    	<b> Handel:</b> 
        </font>
    	</td>
    	
    	<td width=400><input type="text" name="Handel" size=20></td>
      </tr>
    
      <tr>
        <td width=100>
        <font face="arial" size=2>
    	<b>Age:</b>
        </font>
    	</td>
    	
    	<td width=400><input type="text" name="Age" size=20></td>
      </tr>
    
      <tr>
        <td width=100>
        <font face="arial" size=2>
    	<b> Email:</b> 
        </font>
    	</td>
    	
    	<td width=400><input type="text" name="Email" size=50></td>
      </tr>
      <tr>
        <td width=100> </td>
    	<td width=400><br>
    	<input type="submit" value="Submit">
    	<input type="hidden" name="Flag" value=1>
    	 <input type="reset" value="Clear"></form>
    	</td>
      </tr>
    
    </table>
    <%
    End If
    If Flag = 1 then
    	If IsEmpty(request.form("FirstName")) or request.form("FirstName")="" then
    		response.write "<center><font face='arial' size=4>"
    		response.write "<p><br><b>You must enter a First Name.</b></font>"
    		response.write "<form>"
    		response.write "<input type='button' value='Retry' onclick=history.back()>"
    		response.write "</form>"
    		response.end
    	Else
    		FirstName = request.form("FirstName")
    	End If
    
    	If IsEmpty(request.form("LastName")) or request.form("LastName")="" then
    		response.write "<center><font face='arial' size=4>"
    		response.write "<p><br><b>You must enter a Last Name.</b></font>"
    		response.write "<form>"
    		response.write "<input type='button' value='Retry' onclick=history.back()>"
    		response.write "</form>"
    		response.end
    	Else
    		LastName = request.form("LastName")
    	End If
    
    	Handel = request.form("Handel")
    	Age = request.form("Age")
    	Email = request.form("Email")
    
    	Flag = request.form("Flag")
    
    %>
    <table width=400 border=0>
      <tr>
        <td width=400>
         <font face="arial" size=2>
    	 <br>Here is the information you're submitting. If you would like to 
    	 make changes, please use the appropriate button below, or use the other
    	 button to submit this entry as it is.
    	 <br>
    	 <br><b>First Name:</b> <%= FirstName %>
    	 <br><b>Last Name: </b> <%= LastName %>
    	 <br><b>Handel: </b> <%= Handel %>
    	 <br><b>Age: </b> <%= Age %>
    	 <br><b>Email: </b> <%= Email %>
    	<form action="add1.asp" method="post">
    	<input type="hidden" name="FirstName" value="<%= FirstName %>">
    	<input type="hidden" name="LastName" value="<%= LastName %>">
    	<input type="hidden" name="Handel" value="<%= Handel %>">
    	<input type="hidden" name="Age" value="<%= Age %>">
    	<input type="hidden" name="Email" value="<%= Email %>">
    	<input type="hidden" name="Flag" value=2>
    	<input type="submit" value="Yes, Submit it!"> 
    	<input type="button" value="Let's Try Again" onClick="history.go(-1)">
    	</form></font>
        </td>
      </tr>
    </table>
    <%
    End If
    If Flag = 2 then
    	Today = Now()
    		FirstName = request.form("FirstName")
    		FirstName = Replace(FirstName, "'", "''")
    		FirstName = Replace(FirstName, Chr(34), "''")
    		
    		LastName = request.form("LastName")
    		LastName = Replace(LastName, "'", "''")
    		LastName = Replace(LastName, Chr(34), "''")
    		
    		Handel = request.form("Handel")
    		Handel = Replace(Handel, "'", "''")
    		Handel = Replace(Handel, Chr(34), "''")
    
    		Email = request.form("Email")
    		
    		Age = request.form("Age")
    
    	
    	Session.timeout = 15
    	Set conn = Server.CreateObject("ADODB.Connection")
    	conn.open "lan"
    	Set Session("MyDB_conn") = conn
    	
    	
    	'SQLstmt = "INSERT INTO lanreg (First,Last,Handel,Age,Email) VALUES ("& FirstName &" , "& LastName &" , " & Handel & " , " & Age & " , " & Email & ")"
    
    
    	strSQLQuery = "INSERT INTO lanreg (First, Last, Handel, Age, Email) VALUES ("& FirstName &", "& LastName &", " & Handel & ", " & Age & ", " & Email & ")"
    
    	Set rs = Server.CreateObject("ADODB.Recordset")
    	rs.Open strSQLQuery, conn, 3, 3	                  <!-- This Is Where the Error Is. Line 173 -->
    
    	If err.number>0 then
       		response.write "VBScript Errors Occured:" & "<P>"
        	response.write "Error Number=" & err.number & "<P>"
        	response.write "Error Descr.=" & err.description & "<P>"
        	response.write "Help Context=" & err.helpcontext & "<P>" 
        	response.write "Help Path=" & err.helppath & "<P>"
        	response.write "Native Error=" & err.nativeerror & "<P>"
        	response.write "Source=" & err.source & "<P>"
        	response.write "SQLState=" & err.sqlstate & "<P>"
       	end if
       	IF conn.errors.count> 0 then
        	response.write "Database Errors Occured" & "<P>"
        	response.write SQLstmt & "<P>"
       		for counter= 0 to conn.errors.count
        		response.write "Error #" & conn.errors(counter).number & "<P>"
        		response.write "Error desc. -> " & conn.errors(counter).description & "<P>"
       		next
       	else
        	response.write "<br><br><font face='arial' size=4><b>"
    		response.write "Thank you! Your entry has been added.</font><p>"
        	response.write "<font face='arial' size=2>"
    		response.write "<a href='default.asp'>View Guestbook</a>"
       	end if
       	Conn.Close
    	Set conn = nothing
    
    End If
    %>
    </center>
    </body>
    </html>

    I have tried both DSN and DSN-Less but they both seem to have the same error, on the webserver mentioned above it uses DSN.

    I used an Access 2000 Database - do I need to get an updated odbc driver or something??

    I am using Microsoft Personal Web Server on Windows 98.

    Thanks For Any Help

    Hurgh

  2. #2
    Frenzied Member monte96's Avatar
    Join Date
    Sep 2000
    Location
    Somewhere in AZ
    Posts
    1,379
    You are trying to assign the results of an action query to a recordset.

    An Insert statement does not return a recordset.

    You don't even need a recordset for what your doing.. try using the execute method of your connection object instead.


    Also, your never closing the recordset object and setting it to Nothing. (Not that it ever gets opened but the object is created then orphaned)
    oOOo--oOOo
    __/\/\onte96
    oOOo--oOOo
    Senior Programmer/Analyst
    MCP
    [email protected]
    [email protected]


    Your results may vary.. some restrictions may apply.. pricing and participation may vary.. not available in all states.. professional driver closed course..quantities limited..

  3. #3

    Thread Starter
    Addicted Member
    Join Date
    Aug 2000
    Location
    Australia
    Posts
    149

    Thanks

    Thanks for your help, I got it to work in the end.

    Hurgh

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width