Link to home
Start Free TrialLog in
Avatar of Stiebel Eltron
Stiebel EltronFlag for Thailand

asked on

Web Search Engine

Hi! I have another query, it's regarding search engine for our web. U can see below for my script. From my Database, if the PartNo is set to TEXT, it will give an error result or even if the Part Number is typed correct from the SEARCH.ASP page, it'll give a result "Sorry, but Part Number xxxxxxx was not found!" Then I tried to change the properties of the PartNo into NUMBER, it worked! It showed the result that I needed. But the problem is, what if the Part No. is consisting of Alpha Numeric, how can I do it? Please advise...
Everytime I receive error, it's regarding to the row from the code in whereas it's the "Dim sqlString".

Or any advise for a better search engine that we can use for our web?
Thank you in advance & hope to hear soon!
<%
 
	Dim myConnection
	Dim rsSTEProducts
	Dim connectString
	Dim sqlString
	Dim requestPartNo
 
	connectString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & Server.MapPath("ste-prod.mdb")
 
	Set myConnection = Server.CreateObject("ADODB.Connection")
	Set rsSTEProducts = Server.CreateObject("ADODB.Recordset")
 
	myConnection.Open connectString
 
	requestPartNo = Request.Form("PartNo")
 
	sqlString = "Select * From STEProducts WHERE PartNo = " & requestPartNo
	
	Set rsSTEProducts = myConnection.Execute(sqlString)
	
	If (rsSTEProducts.BOF) AND (rsSTEProducts.EOF) then
		Response.Write("Sorry, but Part Number " & requestPartNo & " was not found.")
	ELSE
 
%>
 
        
<table width=47% align=left style="border:5px groove white;" border=1 bordercolor="#333333" bgcolor="#CCCCCC">
<% do while not rsSTEProducts.EOF %>
                    <tr>
						<td align=right bgcolor="#333333" nowrap="nowrap">
							<font color="#ffffff" size=2><b><i>PART NO.</i></b></font>                        
                        </td>
                        <td bgcolor="#FFFFFF" align=left nowrap="nowrap">
							<font face="verdana" size=2>
								<%=rsSTEProducts("PartNo")%></b></a>							
                            </font>						
                        </td>
                    </tr>
                    <tr>
						<td align=right bgcolor="#333333" nowrap="nowrap">
							<font color="#ffffff" size=2><b><i>PRODUCT NAME</i></b></font>                        
                        </td>
                        <td bgcolor="#FFFFFF" align=left nowrap="nowrap">
							<font face="verdana" size=2 color="#0000CC">
						  		<b><%=rsSTEProducts("ProductName")%></b>
                          	</font>				
                        </td>
                    </tr>
                    <tr>
				  		<td align=right bgcolor="#333333" nowrap="nowrap">
							<font color="#ffffff" size=2><b><i>SERIES</i></b></font>                        
                        </td>
                        <td bgcolor="#FFFFFF" align=left nowrap="nowrap">
							<font face="verdana" size=2 color="#0000CC">
						    	<b><%=rsSTEProducts("Series")%></b>
                            </font>		
                        </td>
                    </tr>
                    <tr>
				 		<td align=right bgcolor="#333333" nowrap="nowrap">
							<font color="#ffffff" size=2><b><i>POWER</i></b></font>                        
                        </td>
                        <td bgcolor="#FFFFFF" align=left nowrap="nowrap">
							<font face="verdana" size=2>
								<%=rsSTEProducts("Power")%>							
                            </font>
                        </td>
				  </tr>
                    <tr>
				 		<td align=right bgcolor="#333333" nowrap="nowrap">
							<font color="#ffffff" size=2><b><i>ELSD</i></b></font>                        
                        </td>
                        <td bgcolor="#FFFFFF" align=left nowrap="nowrap">
							<font face="verdana" size=2>
								<%=rsSTEProducts("ELSD")%>							
                            </font>
                        </td>
				  </tr>
                    <tr>
				 		<td align=right bgcolor="#333333" nowrap="nowrap">
							<font color="#ffffff" size=2><b><i>TYPE</i></b></font>                        
                        </td>
                        <td bgcolor="#FFFFFF" align=left nowrap="nowrap">
							<font face="verdana" size=2>
								<%=rsSTEProducts("Type")%>							
                            </font>
                        </td>
				  </tr>
                    <tr>
				 		<td align=right bgcolor="#333333" nowrap="nowrap">
							<font color="#ffffff" size=2><b><i>BRAND</i></b></font>                        
                        </td>
                        <td bgcolor="#FFFFFF" align=left nowrap="nowrap">
							<font face="verdana" size=2>
								<%=rsSTEProducts("Brand")%>							
                            </font>
                        </td>
				  </tr>
<tr>
				 		<td align=right bgcolor="#333333" nowrap="nowrap">
							<font color="#ffffff" size=2><b><i>FEATURES</i></b></font>                        
                        </td>
                        <td bgcolor="#FFFFFF" align=left nowrap="nowrap">
							<font face="verdana" size=2>
								<%=rsSTEProducts("Feat")%>							
                            </font>
                        </td>
				  </tr>
                  <tr>
				 		<td align=right bgcolor="#333333" nowrap="nowrap">
							<font color="#ffffff" size=2><b><i>VARIANCE</i></b></font>                        
                        </td>
                        <td bgcolor="#FFFFFF" align=left nowrap="nowrap">
							<font face="verdana" size=2>
								<%=rsSTEProducts("Variance")%>							
                            </font>
                        </td>
				  </tr>
                  <tr>
				 		<td align=right bgcolor="#333333" nowrap="nowrap">
							<font color="#ffffff" size=2><b><i>SWITCH TYPE</i></b></font>                        
                        </td>
                        <td bgcolor="#FFFFFF" align=left nowrap="nowrap">
							<font face="verdana" size=2>
								<%=rsSTEProducts("SwitchType")%>							
                            </font>
                        </td>
				  </tr>
                  <tr>
				 		<td align=right bgcolor="#333333" nowrap="nowrap">
							<font color="#ffffff" size=2><b><i>CURRENT (AMP)</i></b></font>                        
                        </td>
                        <td bgcolor="#FFFFFF" align=left nowrap="nowrap">
							<font face="verdana" size=2>
								<%=rsSTEProducts("Current(AMP)")%>							
                            </font>
                        </td>
				  </tr>
                  <tr>
				 		<td align=right bgcolor="#333333" nowrap="nowrap">
							<font color="#ffffff" size=2><b><i>VOLTAGE</i></b></font>                        
                        </td>
                        <td bgcolor="#FFFFFF" align=left nowrap="nowrap">
							<font face="verdana" size=2>
								<%=rsSTEProducts("Voltage")%>							
                            </font>
                        </td>
				  </tr>
				  <tr>
				 		<td align=right bgcolor="#333333" nowrap="nowrap">
							<font color="#ffffff" size=2><b><i>BREAKER</i></b></font>                        
                        </td>
                        <td bgcolor="#FFFFFF" align=left nowrap="nowrap">
							<font face="verdana" size=2>
								<%=rsSTEProducts("Breaker")%>							
                            </font>
                        </td>
				  </tr>
				  <tr>
				 		<td align=right bgcolor="#333333" nowrap="nowrap">
							<font color="#ffffff" size=2><b><i>CABLE SIZE</i></b></font>                        
                        </td>
                        <td bgcolor="#FFFFFF" align=left nowrap="nowrap">
							<font face="verdana" size=2>
								<%=rsSTEProducts("CableSize")%>							
                            </font>
                        </td>
				  </tr>
                  <tr>
				 		<td align=right bgcolor="#333333" nowrap="nowrap">
							<font color="#ffffff" size=2><b><i>MOUNTING</i></b></font>                        
                        </td>
                        <td bgcolor="#FFFFFF" align=left nowrap="nowrap">
							<font face="verdana" size=2>
								<%=rsSTEProducts("Mounting")%>							
                            </font>
                        </td>
				  </tr>
                  <tr>
				 		<td align=right bgcolor="#333333" nowrap="nowrap">
							<font color="#ffffff" size=2><b><i>MIN FLOW ON</i></b></font>                        
                        </td>
                        <td bgcolor="#FFFFFF" align=left nowrap="nowrap">
							<font face="verdana" size=2>
								<%=rsSTEProducts("MinFlowOn")%>							
                            </font>
                        </td>
				  </tr>
                  <tr>
				 		<td align=right bgcolor="#999999" nowrap="nowrap" colspan="2">&nbsp;
							
                    </td>
				  </tr>
                  
	<% rsSTEProducts.MoveNext %>
	<% loop %>

Open in new window

Avatar of Wayne Barron
Wayne Barron
Flag of United States of America image

If you are going to do TEXT
Then do this

sqlString = "Select * From STEProducts WHERE PartNo = '" & requestPartNo & "'"

Adding the SINGLE QUOTE
To the front, makes it into Text. To where having only a Double Quote, makes it into NUMBER.
So, try that and see what happes.

Carrzkiss
Avatar of Stiebel Eltron

ASKER

Hello there carrzkiss, thanks for your prompt support. but it didn't helped.
Got error on that line. sqlString = "Select * From STEProducts WHERE PartNo = '" & requestPartNo & "'"
I even changed the type of the PartNo into TEXT, from NUMBER to TEXT, but didn't help.

Any other advise?

Thank you! Wait for soonest reply.
Works for me.
type in the following PartNo:              55te55
http://ee.cffcs.com/Q_24729748/Search.asp
code
http://ee.cffcs.com/Q_24729748/Q_24729748.zip

I do not know the structure of your DB so I have to improvise.
The PartNo Column is of Type: Text

Always list your columns in your Select Statement (As demostrated in my example mdb)
Never use the Wildcard * in your Select Statement as it puts a strain on the Server when doing a lookup.

Good Luck
Let me know if you have any questions?
Carrzkiss
Hello there carrzkiss! GOOD NEWS! It Worked! Thanks for your great help!
BUT! There's a "BUT" hehe!! Why when I change the query to "Series", I mean I changed the query to search for SERIES, it couldn't find anything, it just show "Sorry, but Series was not found.". The series type didn't even show on the result page, "Sorry, but Series xx was not found."
It's just a text type as well. the series types are just (DJ, DL, DS, IJ, DSC, etc.), I tried anything but no result shown on the result page. I followed patterned to your database, create a search query as well, that's why my Search page for PartNo was successful. But for searching the Series, it failed me.

And I want the data on the table be on the right, not looping below. After it show the result, all the ProductName, Power, etc. that have that series will loop onto the right, not below the first table.
Bec. I need to put a link for the ProductName to show the specific details of that item only using their ID's.

So if I type on the search page "DS", it will show on the result page all the DS types, with ProductName, Power, PartNo, etc. Then if I click the ProductName, it will go to the specific product page only.

Wait for your reply again soon!

Thanks in advance again...
Here's my code carrzkiss: Kindly check if there are some mistakes.

<%

      Dim myConnection
      Dim rsSTEProducts
      Dim connectString
      Dim sqlString
      Dim requestSeries

      connectString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & Server.MapPath("ste-prod.mdb")

      Set myConnection = Server.CreateObject("ADODB.Connection")
      Set rsSTEProducts = Server.CreateObject("ADODB.Recordset")

      myConnection.Open connectString

      requestSeries = Request.Form("Series")
      
      sqlString = "SELECT Series, PartNo, ProductName, Power, ELSD, Type, Brand, Feat, Variance, SwitchType, [Current(AMP)], Voltage, Breaker, CableSize, Mounting, MinFlowOn FROM STEProducts WHERE Series='"&requestSeries&"'"

      Set rsSTEProducts = myConnection.Execute(sqlString)
      
      If (rsSTEProducts.BOF) AND (rsSTEProducts.EOF) then
            Response.Write("Sorry, but Series " & requestSeries & " was not found.")
      ELSE

%>
are you doing multi-part searching?
As in, are you searching through different Columns.
The example that I sent over to you searches the [PartNo] Column.
And now you are searching the [Series] Column.

Are you going to be searching through-out all the columns in your Table?
ASKER CERTIFIED SOLUTION
Avatar of Wayne Barron
Wayne Barron
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Hello to you again Carrzkiss!
Here's my response to your questions:
You asked me if I'm going to be searching all through out the columns, no I'm not. I test searching using the PartNo. but later on I think it'll not work as we have SO MANY PART NOS. and no one can memorize them all. So I've decided to go on the series bec. it's much easier to know & remember.

Regarding the format, kindly check the attached excel file for the sample format that I want for the result page.
All the columns should not be repeated, it should be on the left side only, like what I've said we have almost 30 column fields. You just shown 3 of our columns, 27 more. :-)
Then the ProductName will be clickable & go to its specific page, like what you did. I'll study what you did.
QUESTION: What is the help or purpose of the (List & Search) under Queries in the database?

Wait for your reply soon!

Regards,
Sample-Table.xls
This is not actually part of this question.
I have already answered this question 2 times.

I will look at what you have here, but please keep in mind that this is not part of the original question.
This is by no means that best way of doing this.
But is all that I could come up with.

http://ee.cffcs.com/Q_24729748/Search.asp
Do a search for either of the following:  DJ, DL, DS, IJ, DSC

Let me know if this is what you are wanting.

Carrzkiss
Hello there carrzkiss! YES! That's what I want! U got what I mean. I want to give you POINTS now! :-) But we're not yet done.

Wait for your zip files again. :-)

I have question for you, but you haven't answered yet:
QUESTION: What is the help or purpose of the (List & Search) under Queries in the database?

Thank you so much!
stiebel:
I do not mean this in a bad way towards you, but "YES" we are done with this question.
Please read your original question.
You had problems with the search returning results.
I gave you working examples with code 2 times showing you how to implement this search feature into your own environment.

NOW
You ask in mid-thread to have another feature added to it, because you needed it to look a certain way.
Here => http:#a25347402
OK.
I stated that it was not part of the original question and that I had already answered this question 2 times. Posted here: => http:#a25347613

Now
I have absolutely no problem with turning over the code, but in order for me to do that; you will need to open another question. As I have stated: This last code is not part of this question as I stated BEFORE I posted the working page. Posted here: => http:#a25347613

According to EE, if you are going to ask more than 1 question, you need to open another question for it.
So
I ask, out of respect for my hard work, that you accept either one of the 2 above post
1st: http:#a25333408
(or)
2nd: http:#a25344656

As both of them do what this Question asked.
Once you have completed this part and accepted one of the above 2 post as Answer.
All you have to do is create another post and if I get to it before someone else, I will post.
Please do not post the link in here, as EE is getting strict on link posting unless the Threads are not returning results.

I will let it up to you.
Once again
I do not mean to be an a** in this issue, it is just that I spent a couple of days helping you in this one issue.
That should have already been finalized yesterday.

I am getting off here in about 30 minutes
It is 11:23pm EST USA
I will be off here before 12:00am EST, if you can post before then, I will get the message in my mail that it is posted (I get all new ASP post in my inbox), I will reply, if not, I will check it out tomorrow.

Have a good one.
No hard feelings, and sorry for the long drawn out message, but I need for you to understand why?

Carrzkiss
Hi there Carrzkiss! Oh sorry, you misinterpret it. This is the problem if 2 people are talking but not seeing each other, there are sometimes misunderstanding the way they write the message.

As a matter of fact, I'm so happy that there's someone like you who could help me out with this scripting that i need to do. I stopped writing web pages using ASP many years ago, and just recently I started again to revive my skills with this scope. Way back 10yrs ago, I have 1 guy who helped me, we're both helping each other, but I don't know where is he in this world right now. hahaha!!! :-)

For my answer to your question, I chose the 2nd: http:#a25344656.

I would like to say sorry as well, as I'm not that expert in writing ASP Scripts, I'm just riviving it again, so i can be expert like you. :-)

I'll test the scripts that you sent. The 2nd: http:#a25344656

Thank you again!
not a problem
Once you accept and finalize this one, and open the next one I will post the code.
I am heading off to bed now, so I will check it out in about 6 hrs from now.

Have a good one.
Carrzkiss
Dear Carrzkiss,

I already did it! I analyze your scripts & got the idea.
I even change some fields from the first result & expand more.

regarding colspan of 1 <td colspan="?">&nbsp;</td> how can I make it auto adjust everytime the cell will expand bec. of the info from the database. If I put colspan=3, then the data is more than 3, it will not be exact from the table.

So I'll just say Good Morning to you, when you read this message, bec. it's evening time when you read this message.

Thanks a lot!
Great help carrzkiss!
Which are you referring too?
The Results page (or) the produces page?

The products page, you will not want to do a colspan for the data.
Just let the data wrap in the Table Cell on it's own.
This will make it look a lot nicer.

If you are referring to the Results.asp page, then I would also allow it to wrap itself within
The Table Cell.
It will make it a lot easier to deal with.
Besides.
I would (myself) rather have the text wrap itself within the cell, instead of having long information
That causes a scrollbar at the bottom of the page to appear when the data overflows to the side(s) of the page, there is nothing more ugly on a page then to have that happen.
(EE use to be like that back when I first signed up on the site, and I hated it. And was one of my suggestions for the future of EE was to some how do a "Wrap" instead of allow the text to free-flow)
=-=-=-=-=-=-=-=-=-=-=-=-=-=
Glad that you got it working.
Did you go with the way you wanted to? Or another way.
I would like to see the results page if it is different then what I originally posted to you?
Carrzkiss