Wrox Programmer Forums
|
ASP E-commerce As of Oct 5, 2005, this forum is now locked. No posts have been deleted. Please use "Classic ASP Professional" at: http://p2p.wrox.com/forum.asp?FORUM_ID=56 for discussions similar to the old ASP Pro Code Clinic or one of the other many remaining ASP and ASP.NET forums here.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the ASP E-commerce 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 April 5th, 2004, 06:37 PM
Authorized User
 
Join Date: Jun 2003
Posts: 12
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via Yahoo to victorcorey
Default Modifing code to work with Microsoft Access

Hello Everyone,

I am working on modifying the code in Beginning ASP.NET E-Commerce With Visual Basic .NET and Visual Studio .NET. I am currently in Chapter 5 Searching the Catalog. I have modified the stored procedures into Access queries, instead of one query to decide to search for All Words or Any Words I created two different queries then call them separately in the Catalog class.

So for the queries work in Access and I have written the code to pass in the parameters. Everything is working without thowing any errors, but I don't get any results. Any ideas? (code is below)

    Public Function SearchCatalog(ByVal searchString As String, ByVal allWords As String) As OleDbDataReader

        ' Create the connection object
        Dim connection As New OleDbConnection(connectionString)
        Dim command As New OleDbCommand

        ' We guard agains bogus values here - if we receive anything
        ' different than "TRUE" we assume it's "FALSE"
        If allWords.ToUpper = "TRUE" Then
            ' Create and initialize the command object and search all words
            command.CommandText = "SearchCatalogAllWords"
            command.Connection = connection
            command.CommandType = CommandType.StoredProcedure
        Else
            ' Create and initialize the command object and search any words
            command.CommandText = "SearchCatalogAnyWords"
            command.Connection = connection
            command.CommandType = CommandType.StoredProcedure
        End If

        ' We eliminate separation characters
        searchString = searchString.Replace(",", " ")
        searchString = searchString.Replace(";", " ")
        searchString = searchString.Replace(".", " ")

        ' We create an array which contains the words
        Dim words() As String = Split(searchString, " ")

        ' wordsCount contains the total number of words
        Dim wordsCount As Integer = words.Length
        ' index is used to parse the list of words
        Dim index As Integer = 0
        ' this will store the total number of added words
        Dim addedWords As Integer = 0

        ' We allow a maximum of 5 words
        While addedWords < 5 And index < 5
            ' We add the @searchWord parameters here
            If addedWords < wordsCount Then
                addedWords += 1
                ' Add an input parameter and supply a value for it
                command.Parameters.Add("@searchWord" + addedWords.ToString, words(index))
            Else
                addedWords += 1
                ' Add a blank input parameter
                command.Parameters.Add("@searchWord" + addedWords.ToString, "")
            End If
            index += 1
        End While
        ' Open the connection
        connection.Open()

        ' Return a SqlDataReader to the calling function
        Return command.ExecuteReader(CommandBehavior.CloseConnect ion)
    End Function

--
Victor Corey
__________________
--
Victor Corey





Similar Threads
Thread Thread Starter Forum Replies Last Post
Code to make crystal viewer (10) work with access Charinator Access 0 November 16th, 2006 05:26 AM
Half the code in Access 2000 VBA doesn't work disruptivehair BOOK: Beginning Access VBA 0 December 26th, 2005 02:21 PM
[Microsoft][ODBC Microsoft Access Driver] Syntax e chinedu Classic ASP Databases 3 November 18th, 2004 03:48 PM
Microsoft Works to Microsoft Access lryckman Access 4 April 12th, 2004 03:17 PM
Why does Microsoft.XMLHTTP not work? mega XML 2 August 12th, 2003 07:59 AM





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