Results 1 to 2 of 2
  1. #1
    Join Date
    May 2012

    Unanswered: What is wrong in my sql statement

    I am trying to create a search using sql statement and I want the result to show up in the same page just below the searchform. But I keep getting the following error everytime I try to search for a number.

    Microsoft JET Database Engine error '80040e10'
    No value given for one or more required parameters.
    /search-form2.asp, line 41

    Here is the link to the page. Untitled Document

    If you try to search for the following number. (all searches will be for numbers in this format) 979 498 071 -you will see the error I am getting.

    I will also provide the code for the page.

    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "">
    <html xmlns="">
    <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
    <title>Untitled Document</title>
    Dim strURL, cnnSearch, rstSearch, strDBPath, strSQL, strSearch
    strURL = Request.ServerVariables("URL")
    strSearch = Request.QueryString("search")
    <p>Søk etter organisasjonsnummer</p>
    <form action="<%= strURL %>" method="get">
    <input name="search" value="<%= strSearch %>" />
    <input type="submit" value="Hent" />
    If strSearch <> "" Then
    	strDBPath = Server.MapPath("kunder.mdb")
    	Set cnnSearch = Server.CreateObject("ADODB.Connection")
    	'cnnSearch.Open "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\inetpub\wwwroot\nina-saether\www\Databaser\kunder.mdb;Persist Security Info=False"
    		cnnSearch.Open "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=D:\home\studio36\www\Databaser\kunder.mdb;Persist Security Info=False"
    	strSQL = "SELECT * FROM kunder WHERE Org-nr LIKE '" & strSearch & "'"
    	Set rstSearch = cnnSearch.Execute(strSQL)
    	<table border="1">
    	Do While Not rstSearch.EOF
    		<td><%= rstSearch.Fields("Org-nr").Value %> <br />
    			 <%= rstSearch.Fields("Navn").Value %> <br />
    			 <%= rstSearch.Fields("Tlf").Value %> <br />
                 <%= rstSearch.Fields("Mobil").Value %> <br />
                 <%= rstSearch.Fields("E-post").Value %> <br /> 
    	Set rstSearch = Nothing
    	Set cnnSearch = Nothing
    End If
    Any help would be greatly appreciated.

  2. #2
    Join Date
    Apr 2002
    Toronto, Canada
    a little bird whispered the following about three hours ago...
    Have you verified that strSearch is being populated when you do the Request.QueryString?

    Have you verified that the query works if you hard code something into the LIKE ''?

    Is kunder the name of the table? I ask because that is the name of the database.
    if you had tested the query by itself, i think you would have discovered that it will fail because it doesn't recognize the "Org" and "nr" columns that you appear to be trying to subtract there

    ... which is a roundabout way of saying that [Org-nr] needs brackets because the column name contains a special character

    Last edited by r937; 05-17-12 at 15:22. | @rudydotca
    Buy my SitePoint book: Simply SQL

Posting Permissions

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