473,503 Members | 1,641 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Microsoft OLE DB Provider for ODBC Drivers (0x80040E14) [Microsoft][ODBC Microsoft Ac

16 New Member
Hi I have written a search function to Search through my database but i get this error could anyone please assist as this is quite urgent.
Expand|Select|Wrap|Line Numbers
  1. <%@LANGUAGE="VBSCRIPT" CODEPAGE="1252"%>
  2. <!--#include file="Connections/Connect.asp" -->
  3. <%
  4. Set objconn = Server.CreateObject("ADODB.Connection")
  5. objconn.ConnectionString = "DRIVER=Microsoft Access Driver (*.mdb);DBQ=" & Server.MapPath("mypath")
  6. objconn.Open%>
  7. <%
  8. Dim rsQryDisplayFields
  9. Dim rsQryDisplayFields_numRows
  10.  
  11. Set rsQryDisplayFields = Server.CreateObject("ADODB.Recordset")
  12. rsQryDisplayFields.ActiveConnection = objconn
  13. rsQryDisplayFields.Source = "SELECT DISTINCT RiskCategoryID,RiskCategory, RiskRef, RiskDescription, APName, APRef, BusinessUnit, ProcessName, Application_Name, Database_Management_System, Operating_System_Name, Physical_Infrastructure_Filepath, Network_Infrastructure_Filepath  FROM qryDisplayFields"
  14. rsQryDisplayFields.CursorType = 0
  15. rsQryDisplayFields.CursorLocation = 2
  16. rsQryDisplayFields.LockType = 1
  17. rsQryDisplayFields.Open()
  18.  
  19. rsQryDisplayFields_numRows = 0
  20. %>
  21.  
  22. <%
  23.  
  24.  
  25. 'the words entered in the text field stored in a text string in a variable called Keywords
  26. Keywords = Request("txtKeywords2")
  27.  
  28. 'The seleted sea5rch type - All words = AND, Any Words = OR, Exact Phrase = EXACT
  29. 'Stored in a variable called Matchtype
  30. MatchType = Request("selMatchType")
  31.  
  32. If Keywords <> "" then 'if there is something in the keywords 
  33.  
  34.     Searchfields = "CombinedFields" 'Database table column in which we are going look for matches to our keywords
  35.  
  36.     'stored in a textfield variabled called Searhfields
  37.  
  38.     Keywords = replace(Keywords, "'" , "''") 'Replace any single quotes with 2 quotes, to stop the search failing , but matches with words with apostrophes.
  39.  
  40.     If (MatchType <> "EXACT") Then    ' If Searchtype is not EXACT
  41.  
  42.         Keywords = Replace(Keywords, ","," ")     ' Replace any commas, colons, semicolons, dashes, undersores,
  43.         Keywords = Replace(Keywords, ":"," ")     ' forward slashes or back slashes in the text entered in the
  44.         Keywords = Replace(Keywords, ";"," ")     ' Keywords text field with a space.
  45.         Keywords = Replace(Keywords, "-"," ")
  46.         Keywords = Replace(Keywords, "_"," ")
  47.         Keywords = Replace(Keywords, "/"," ")
  48.         Keywords = Replace(Keywords, "\"," ")
  49.         WhereKeywordsString = "WHERE" & Searchfields & " LIKE '%" ' The sql statment where clause stored as text
  50.  
  51.         SearchArray = Split(Keywords," ") 'Split kewyords that are now separated by spaces and sted them in an array
  52.  
  53.         For i = 0 to Ubound(SearchArray)' Repeat the following for each word in the array
  54.  
  55.             if i > 0 Then 
  56.                 WhereKeywordsString = WhereKeywordsString & " " & MatchType & " " & Searchfields & " LIKE '%"  & SearchArray(i) & "%'"' Builds the SWL statment substituting AND/ OR as defined by Matchtype
  57.             Else
  58.                 WhereKeywordsString = WhereKeywordsString & SearchArray(i) & "%'" ' If there is only one word in the array
  59.             End if 
  60.         Next
  61.     Else
  62.  
  63.         WhereKeywordsString = " WHERE CombinedFields LIKE '%" & Keywords & "%'" 'If the search Type seleted was EXACT 
  64.     End if  'End if Searchtype is not EXACT
  65.     Response.Write(WhereKeywordsString)
  66.  
  67. %>
  68. <%
  69.     set rsQryCombinedFields = Server.CreateObject("ADODB.Recordset")
  70.     rsQryCombinedFields.ActiveConnection = objconn
  71.     rsQryCombinedFields.Source = "SELECT DISTINCT RiskCategoryID From qryMatrixAll" & WhereKeywordsString 
  72.     rsQryCombinedFields.CursorType = 0
  73.     rsQryCombinedFields.CursorLocation = 2
  74.     rsQryCombinedFields.LockType = 1
  75.     rsQryCombinedFields.Open()
  76.     rsQryCombinedFields_numRows = 0    
  77.     %>
Expand|Select|Wrap|Line Numbers
  1. Syntax error in from clause.
  2. Error on line 74
And whats funny is that sometimes it works and sometimes it doesnt.
Jul 4 '07 #1
6 5403
jhardman
3,406 Recognized Expert Specialist
There are several things that can go wrong here, several of them involve special characters that need to be escaped (or changed to safe characters) before sending them to the db, I would guess this is causing the problem, probably in the variable WhereKeywordString. I notice that you response.write the WhereKeywordString before you pass it to the db. When you get the error, what is the exact value of this variable?

Jared
Jul 5 '07 #2
Genken
16 New Member
There are several things that can go wrong here, several of them involve special characters that need to be escaped (or changed to safe characters) before sending them to the db, I would guess this is causing the problem, probably in the variable WhereKeywordString. I notice that you response.write the WhereKeywordString before you pass it to the db. When you get the error, what is the exact value of this variable?

Jared
Well i basically have a search page which is made of 3 different types of Search types namely AND, OR, and EXACT words. If the user clicks on AND i get an error or if the user clicks on OR i get an error , but whenever i click on EXACT the search seems to work fine.

When i click on EXACT list option the search works and the whereKeywordString has the value of
WHERE CombinedFields LIKE '%whatever i type%' .

When i get the error i cant see the whereKeywordString value is there anyway of me seeing what is stored in the whereKeywordString when the error occurs.

Thanks in advance.
Genken
Jul 6 '07 #3
jhardman
3,406 Recognized Expert Specialist
Well i basically have a search page which is made of 3 different types of Search types namely AND, OR, and EXACT words. If the user clicks on AND i get an error or if the user clicks on OR i get an error , but whenever i click on EXACT the search seems to work fine.

When i click on EXACT list option the search works and the whereKeywordString has the value of
WHERE CombinedFields LIKE '%whatever i type%' .

When i get the error i cant see the whereKeywordString value is there anyway of me seeing what is stored in the whereKeywordString when the error occurs.

Thanks in advance.
Genken
that kind of depends on where the error occurs. If the error doesn't come until you connect to the db (after you create and populate the variable) then you should still be able to see it, unless you have some server settings that give "friendly" (worthless) error messages when the asp page gives an error. The error message you described, though, suggests you should see the variable still. At least I don't see any reason why you wouldn't see it.

Jared
Jul 6 '07 #4
Genken
16 New Member
Im really sorri, but i cannot see the variables values when the error occurs only the browser error messages.

Is there anyway how i can force the variable to be displayed in command prompt or somthing i know the error lies with the whereKeywordsString variable.

Please assist.

Thankyou
Genken
Jul 10 '07 #5
jhardman
3,406 Recognized Expert Specialist
Im really sorri, but i cannot see the variables values when the error occurs only the browser error messages.

Is there anyway how i can force the variable to be displayed in command prompt or somthing i know the error lies with the whereKeywordsString variable.

Please assist.

Thankyou
Genken
you could say:
Expand|Select|Wrap|Line Numbers
  1. on error resume next
near the beginning of the script. This might make your page time out, but the variable should be printed.

Jared
Jul 10 '07 #6
Genken
16 New Member
you could say:
Expand|Select|Wrap|Line Numbers
  1. on error resume next
near the beginning of the script. This might make your page time out, but the variable should be printed.

Jared
Hi Thanks for all your assistance and help i got it working today by simply just retyping all my code in a new file. I really couldnt understand why it worked this time, but it did.

I have another question relating to my previous question.

I have everything displaying very nicely now but what i need to do is export all the findings or returning recordset to .csv or .xls format and i have moved from access format to sql server is there help resources you can point me to or do you have some advice.

Thanks in advance
Genken
Jul 12 '07 #7

Sign in to post your reply or Sign up for a free account.

Similar topics

1
9455
by: Tim Groulx | last post by:
Hello All, I am getting the following error when attemping to open a table in SQL2kSP3a. ________________________________________ SQL Server Enterprise Manager Database Server: Microsoft SQL...
1
10272
by: Luigi Ida' via SQLMonster.com | last post by:
Hi, I have a php application connected through odbc to a sqlserver database. When I try to execute select queries on a smalldatetime table field I receive this message: Warning: Numeric value...
10
20961
by: FreeOperator | last post by:
Dear all, On Win2000 server with SP3, I am trying to access a SQL Server 7.0 database, "TestDB", from VB6 via a SQL Server ODBC system DSN using ADO 2.7. In SQL Server Enterprise Manager, there...
4
18029
by: dcarson | last post by:
I've read about this error in several other discussions, but still can't seem to pinpoint the problem with my code. Everything seemed to be working fine for some time, but it now tends to bomb out...
8
40618
by: Dakkar | last post by:
I wrote a program with c# for connecting mysql and taking data from it but when someone without me try to execute the program they are taking this error ERROR Data source name not found and...
0
5879
by: jwtulp | last post by:
Hello all, I receive the following error when updating MSAccess2003 Memo fields using an ODBC connection in ASP.Net 1.1 when the length of the text to be updated exceeds 255 characters....
0
755
by: bazzer | last post by:
hey, i am using visual basic.net 2003 and have an ASP.NET webform application thats accessing a microsoft access 2003 database. i kept getting the following error when i tried to run it: ERROR ...
0
12002
by: bazzer | last post by:
hey, im trying to access a microsoft access database from an ASP.NET web application in visual basic 2003.NET. i get the following error when i try running it: Server Error in...
12
31963
by: bhanu08 | last post by:
I am get this error java.sql.SQLException: Data source name not found and no default driver specified my code for connection is { Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");...
0
7194
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
7070
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
7267
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
1
6976
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
5566
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
4666
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
3160
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
3148
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
729
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.