Wrox Programmer Forums
|
Classic ASP Databases Discuss using ASP 3 to work with data in databases, including ASP Database Setup issues from the old P2P forum on this specific subtopic. See also the book forum Beginning ASP.NET Databases for questions specific to that book. NOT for ASP.NET 1.0, 1.1, or 2.0.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Classic ASP Databases section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old October 16th, 2004, 05:00 PM
Friend of Wrox
 
Join Date: Jul 2004
Posts: 240
Thanks: 0
Thanked 1 Time in 1 Post
Default

ok. I know that there wasn't anything wrong with the query in the previous body of codes. I transferred it hoping to use the "paging". The reason I wanted to show the entire code is because I know there's nothing wrong with it but maybe there was something to include or to take out. The Paging code example had no query searches. It was simply a table displayed.

But here is my SQL once again:
Code:
Sub ShowResults()
    Dim strConn     ' Database connection string
    Dim SQL         ' String that will have our SQL statments
    Dim RS          ' Recordset object
    Dim Keyword     ' Keyword for search
'pageing
    Dim nRecCount   ' Number of records found
    Dim nPageCount  ' Number of pages of records we have
    Dim nPage       ' Current page number
'query
    Dim iCounter
    Dim iLoopCount
    Dim aRecTypes
    Dim spoke       ' For dropdown
    Dim number
    Dim Keywordb
    Dim Keywordc
    Dim intRec


    ' define our SQL statement
    ' we will be looking for all the records in tblItem table 
    ' where ItemName contains our Keyword
    ' do not forget to fix tick marks (single quotes) in our Keyword
    SQL = "SELECT * FROM bible WHERE "
    strConn = GetConnectionString()

    ' Let's see what page are we looking at right now
    nPage = CLng(Request.QueryString("Page"))

    ' Let's see what user wants to search for today :)
    Keyword = Trim(Request.QueryString("Keyword"))
    spoke = Request.Querystring("spoke")
    number = Request.QueryString("number")
    Keywordb = Request.QueryString("Keywordb")
    Keywordc = Request.QueryString("Keywordc")

'Set conn = Server.CreateObject("ADODB.Connection")  
'conn.Open(GetConnectionString)              

iCounter = 0

If   request.QueryString("text_data")="yes" then

  SQL = SQL & "text_data LIKE '%" & Keyword & "%' AND "  
  SQL = SQL & "text_data LIKE '%" & Keywordb & "%' AND "
  SQL = SQL & "text_data LIKE '%" & Keywordc & "%'"

  iCounter = iCounter + 1

end if


If   request.QueryString("book")="yes" then

  If iCounter > 0 Then
    SQL = SQL & " AND "
  End If

  SQL = SQL & "book LIKE '" & number & "'"

  iCounter = iCounter + 1

end if


If   request.QueryString("book_title")="yes" then

  If iCounter > 0 Then
    SQL = SQL & " AND "
  End If

  SQL = SQL & "book_title LIKE '%" & number & "%'"

  iCounter = iCounter + 1

end if

If   request.QueryString("chapter")="yes" then

  If iCounter > 0 Then
    SQL = SQL & " AND "
  End If

  SQL = SQL & "chapter LIKE '%" & number & "%'"

  iCounter = iCounter + 1

end if

If   request.QueryString("verse")="yes" then

  If iCounter > 0 Then
    SQL = SQL & " AND "
  End If

  SQL = SQL & "verse LIKE '%" & number & "%'"

  iCounter = iCounter + 1

end if

If   request.QueryString("book_spoke")="Book_Spoke" then

  If iCounter > 0 Then
    SQL = SQL & " AND "
  End If

  SQL = SQL & "book_spoke = '" & spoke & "'"

  iCounter = iCounter + 1

end if

If   request.QueryString("chapter_spoke")="Chapter_Spoke" then

  If iCounter > 0 Then
    SQL = SQL & " AND "
  End If

  SQL = SQL & "chapter_spoke = '" & spoke & "'"

  iCounter = iCounter + 1

end if

If   request.QueryString("verse_spoke")="Verse_Spoke" then

  If iCounter > 0 Then
    SQL = SQL & " AND "
  End If

  SQL = SQL & "verse_spoke = '" & spoke & "'"

  iCounter = iCounter + 1

end if

If Trim(Request.QueryString("recordType")) <> "" Then


  aRecTypes = Split(Request.QueryString("recordType"), ",")

  If IsArray(aRecTypes) Then 'This is a bit redundant, but it can't hurt
    SQL = SQL & " AND ("

    For iLoopCount = 0 To UBound(aRecTypes)
      If iLoopCount <> 0 Then
        SQL = SQL & " OR "
      End If

      SQL = SQL & " recordType = '" & trim(aRecTypes(iLoopCount)) & "'"
    Next
  End If
  SQL = SQL & ")"
End If

    Set rs = Server.CreateObject("ADODB.Recordset")

    rs.PageSize = 5
    rs.CacheSize = 5
    rs.CursorLocation = adUseClient
    Response.Write SQL
    rs.Open SQL, StrConn, adOpenForwardOnly, adLockReadOnly, adCmdTableDirect
 
Quote:
quote:Microsoft OLE DB Provider for ODBC Drivers error '80040e37'
Quote:
[Microsoft][ODBC Microsoft Access Driver] Syntax error in FROM clause.

/wheelofgod/kjvresp2.asp, line 87
I have done a response.write sql too. There was nothing wrong with it. I even took out all the ifs and left with SQL = "SELECT * FROM bible ". Still no correction.

Isn't there any solution to this?

 
Old October 18th, 2004, 07:17 AM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 1,998
Thanks: 0
Thanked 3 Times in 3 Posts
Default

Hey,

Try changing your rs.Open options. Try removing the adCmdTableDirect. Maybe that's your problem?

Brian





Similar Threads
Thread Thread Starter Forum Replies Last Post
Why does it show error C2228? cupido Visual C++ 2 March 22nd, 2008 10:38 PM
show an error if not checked aku_hardy PHP How-To 1 June 6th, 2007 05:07 AM
show results of SQL in txtbox Loralee Access 3 January 4th, 2007 11:40 AM
Show result during SQL statement rtr1900 ASP.NET 2.0 Basics 0 December 7th, 2006 06:51 AM
SQL not show a certain column ql7500 MySQL 1 January 26th, 2006 08:45 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.