Database Management
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me

The Shed is going Social! Join us on FaceBook and Twitter and chime in on the conversation.

Go Back   Dev Shed ForumsDatabasesDatabase Management

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old May 17th, 2012, 06:34 AM
grissom grissom is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Feb 2005
Posts: 53 grissom User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 19 h 35 m 11 sec
Reputation Power: 9
What is wrong with my sql statment

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. http://www.studio36.no/search-form2.asp

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.

Code:
<%@LANGUAGE="VBSCRIPT" CODEPAGE="1252"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Untitled Document</title>


</head>

<body>

<%

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" />
</form>

<%
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">
	<tr>
	<th>Kundeinformasjon</th>

	</tr>
	<%
	Do While Not rstSearch.EOF
		%>
		<tr>
		<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 /> 
        </td>
		</tr>
		<%
		rstSearch.MoveNext
	Loop
	%>
	</table>
	<%

	rstSearch.Close
	Set rstSearch = Nothing
	cnnSearch.Close
	Set cnnSearch = Nothing
End If

%>

</body>
</html>


Any help on resolving this would be greatly appreciated.

Reply With Quote
  #2  
Old May 17th, 2012, 10:44 AM
Vomster's Avatar
Vomster Vomster is offline
Contributing User
Dev Shed Novice (500 - 999 posts)
 
Join Date: Feb 2005
Posts: 724 Vomster User rank is Captain (20000 - 30000 Reputation Level)Vomster User rank is Captain (20000 - 30000 Reputation Level)Vomster User rank is Captain (20000 - 30000 Reputation Level)Vomster User rank is Captain (20000 - 30000 Reputation Level)Vomster User rank is Captain (20000 - 30000 Reputation Level)Vomster User rank is Captain (20000 - 30000 Reputation Level)Vomster User rank is Captain (20000 - 30000 Reputation Level)Vomster User rank is Captain (20000 - 30000 Reputation Level)Vomster User rank is Captain (20000 - 30000 Reputation Level) 
Time spent in forums: 1 Week 3 Days 2 h 26 m 31 sec
Reputation Power: 290
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 ''?

EDIT

Is kunder the name of the table? I ask because that is the name of the database.

Reply With Quote
  #3  
Old May 17th, 2012, 02:22 PM
r937's Avatar
r937 r937 is offline
SQL Consultant
Click here for more information.
 
Join Date: Feb 2003
Location: Toronto Canada
Posts: 26,376 r937 User rank is General 47th Grade (Above 100000 Reputation Level)r937 User rank is General 47th Grade (Above 100000 Reputation Level)r937 User rank is General 47th Grade (Above 100000 Reputation Level)r937 User rank is General 47th Grade (Above 100000 Reputation Level)r937 User rank is General 47th Grade (Above 100000 Reputation Level)r937 User rank is General 47th Grade (Above 100000 Reputation Level)r937 User rank is General 47th Grade (Above 100000 Reputation Level)r937 User rank is General 47th Grade (Above 100000 Reputation Level)r937 User rank is General 47th Grade (Above 100000 Reputation Level)r937 User rank is General 47th Grade (Above 100000 Reputation Level)r937 User rank is General 47th Grade (Above 100000 Reputation Level)r937 User rank is General 47th Grade (Above 100000 Reputation Level)r937 User rank is General 47th Grade (Above 100000 Reputation Level)r937 User rank is General 47th Grade (Above 100000 Reputation Level)r937 User rank is General 47th Grade (Above 100000 Reputation Level)r937 User rank is General 47th Grade (Above 100000 Reputation Level) 
Time spent in forums: 3 Months 1 Week 2 Days 7 h 35 m 43 sec
Reputation Power: 4140
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

__________________
r937.com | rudy.ca
please visit Simply SQL and buy my book

Reply With Quote
  #4  
Old May 17th, 2012, 03:20 PM
grissom grissom is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Feb 2005
Posts: 53 grissom User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 19 h 35 m 11 sec
Reputation Power: 9
Sorry, I somtimes post in multiple forums hoping to widen the search for an answer.

I have tried to hardcode a number into the sql statement ("SELECT * FROM tblkunder WHERE OrgNr LIKE 990 362 084")which gives me the following error: Syntax error (missing operator) in query expression 'OrgNr LIKE 990 362 084'.

I can see in the URI that ?search=990+362+084 so I guess it is populating.

It's been several years since I worked with asp and sql so I am very, very rusty and I really need som help.

I thought that Org-nr could give me problems so I renamed it to OrgNr. I also renamed the database to dbKunder and the table to tblKunder but no luck.

Any ideas on where I go wrong?

Reply With Quote
  #5  
Old May 17th, 2012, 08:34 PM
r937's Avatar
r937 r937 is offline
SQL Consultant
Click here for more information.
 
Join Date: Feb 2003
Location: Toronto Canada
Posts: 26,376 r937 User rank is General 47th Grade (Above 100000 Reputation Level)r937 User rank is General 47th Grade (Above 100000 Reputation Level)r937 User rank is General 47th Grade (Above 100000 Reputation Level)r937 User rank is General 47th Grade (Above 100000 Reputation Level)r937 User rank is General 47th Grade (Above 100000 Reputation Level)r937 User rank is General 47th Grade (Above 100000 Reputation Level)r937 User rank is General 47th Grade (Above 100000 Reputation Level)r937 User rank is General 47th Grade (Above 100000 Reputation Level)r937 User rank is General 47th Grade (Above 100000 Reputation Level)r937 User rank is General 47th Grade (Above 100000 Reputation Level)r937 User rank is General 47th Grade (Above 100000 Reputation Level)r937 User rank is General 47th Grade (Above 100000 Reputation Level)r937 User rank is General 47th Grade (Above 100000 Reputation Level)r937 User rank is General 47th Grade (Above 100000 Reputation Level)r937 User rank is General 47th Grade (Above 100000 Reputation Level)r937 User rank is General 47th Grade (Above 100000 Reputation Level) 
Time spent in forums: 3 Months 1 Week 2 Days 7 h 35 m 43 sec
Reputation Power: 4140
do you want LIKE or do you want equality?

because LIKE without wildcard characters is the same as an equality test
Code:
SELECT something
     , anything
     , just_not_the_dreaded_evil_select_star
  FROM tblkunder 
 WHERE OrgNr = '990 362 084'

Reply With Quote
  #6  
Old May 18th, 2012, 04:53 AM
grissom grissom is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Feb 2005
Posts: 53 grissom User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 19 h 35 m 11 sec
Reputation Power: 9
Thanks for your reply.

I solved the problem late last night. When removing the space between the numbers in the database it now works.

I am looking for equality, it should match the number exactly, maybe i should use =?

Reply With Quote
  #7  
Old May 18th, 2012, 04:59 AM
r937's Avatar
r937 r937 is offline
SQL Consultant
Click here for more information.
 
Join Date: Feb 2003
Location: Toronto Canada
Posts: 26,376 r937 User rank is General 47th Grade (Above 100000 Reputation Level)r937 User rank is General 47th Grade (Above 100000 Reputation Level)r937 User rank is General 47th Grade (Above 100000 Reputation Level)r937 User rank is General 47th Grade (Above 100000 Reputation Level)r937 User rank is General 47th Grade (Above 100000 Reputation Level)r937 User rank is General 47th Grade (Above 100000 Reputation Level)r937 User rank is General 47th Grade (Above 100000 Reputation Level)r937 User rank is General 47th Grade (Above 100000 Reputation Level)r937 User rank is General 47th Grade (Above 100000 Reputation Level)r937 User rank is General 47th Grade (Above 100000 Reputation Level)r937 User rank is General 47th Grade (Above 100000 Reputation Level)r937 User rank is General 47th Grade (Above 100000 Reputation Level)r937 User rank is General 47th Grade (Above 100000 Reputation Level)r937 User rank is General 47th Grade (Above 100000 Reputation Level)r937 User rank is General 47th Grade (Above 100000 Reputation Level)r937 User rank is General 47th Grade (Above 100000 Reputation Level) 
Time spent in forums: 3 Months 1 Week 2 Days 7 h 35 m 43 sec
Reputation Power: 4140
Quote:
Originally Posted by grissom
I am looking for equality, it should match the number exactly, maybe i should use =?
yep, i think so

Reply With Quote
Reply

Viewing: Dev Shed ForumsDatabasesDatabase Management > What is wrong with my sql statment

Developer Shed Advertisers and Affiliates



Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump

Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 


Powered by: vBulletin Version 3.0.5
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.

© 2003-2013 by Developer Shed. All rights reserved. DS Cluster - Follow our Sitemap