Querying a Database

Results 1 to 3 of 3

Thread: Querying a Database

  1. #1
    Join Date
    Dec 1969

    Default Querying a Database

    Seems simple... I am querying a database. I can display all the records. I create a variable for the querystring, which works fine.<BR><BR>So all I need to do is write the SQL and Open the connection using it... But I get a "Too few parameters. Expected 1" error, pointing to the connection line. The code is below... Any ideas?<BR><BR><BR> &#039Step 1 Create and open Dbase Connection<BR> Dim objConn<BR> Set objConn = Server.CreateObject ("ADODB.Connection")<BR> objConn.Open "nt2189-CarersCentres"<BR><BR> &#039Step 2 Read in the value entered<BR> Dim strQuery <BR> strQuery = Request.QueryString("County")<BR> if strQuery &#060;&#062; "*" then<BR><BR> &#039 Just to test the variable is filled! And it works.<BR> Response.Write strQuery<BR><BR> &#039Step 3 Create SQL variable<BR> Dim strSQL<BR>strSQL = "SELECT * FROM CentreDetails WHERE County=&#039" & strQuery & "&#039 ORDER BY CentreName"<BR> <BR><BR> &#039Step 4 Create a recordset object instance and execute the SQL Statement. Populate with Open method<BR> Dim objRec<BR> Set objRec = Server.CreateObject ("ADODB.Recordset")<BR> objRec.Open strSQL, objConn<BR><BR><BR>

  2. #2
    peter@metza.dk Guest

    Default RE: Querying a Database

    Check your table and column names!

  3. #3
    Join Date
    Dec 1969

    Default RE: Querying a Database THANK YOU!

    You&#039re right!<BR><BR>You, my friend, are a star!!<BR><BR>Thanks very much

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts