SitePoint Sponsor

User Tag List

Results 1 to 4 of 4
  1. #1
    Galactic Overlord gold trophysilver trophybronze trophy
    HAWK's Avatar
    Join Date
    Aug 2003
    Location
    New Zealand
    Posts
    12,540
    Mentioned
    956 Post(s)
    Tagged
    14 Thread(s)

    Select statement not returning recordset

    This is really simple but for some reason no recordset is returning. I can't get cat_1 to write. I have run the query against the database in Query Analyser and it runs fine. Any ideas?

    Code:
    Dim objConn 
    Set objConn = Server.CreateObject("ADODB.Connection") objConn.ConnectionString = "Driver={SQL Server};Server=nzlakldwhse;Database=Complaints;Uid=elkuser;Pwd=elk;" 
    objConn.Open 
     
    Dim objRS 
    Dim cat_id, cat_1, cat_2 
    set objRS = objConn.Execute("select cat_id, cat_1 from complaints.dbo.category a where a.cat_id = '"& request.form("cat_id") &"'") 
     
    response.Write(cat_1) 
    response.End

  2. #2
    SitePoint Enthusiast
    Join Date
    Feb 2005
    Posts
    53
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Do this and see what you get...

    Code:
    response.write select cat_id, cat_1 from complaints.dbo.category a where a.cat_id = '"& request.form("cat_id") &"'"

  3. #3
    Galactic Overlord gold trophysilver trophybronze trophy
    HAWK's Avatar
    Join Date
    Aug 2003
    Location
    New Zealand
    Posts
    12,540
    Mentioned
    956 Post(s)
    Tagged
    14 Thread(s)
    I get a syntax error - shouldn't there be brackets or quotes around the select statement?


    Code:
     
    Syntax error 
     
    /complaints/cat_2_act.asp, line 17 
    response.Write select cat_id, cat_1 from complaints.dbo.category a where a.cat_id = "& request.form("cat_id") &"
    ---------------^

  4. #4
    SitePoint Wizard
    Join Date
    Nov 2004
    Location
    Nelson BC
    Posts
    2,310
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Go back to your original code

    Change
    response.Write(cat_1)
    to
    response.write objRS("cat_1")


Bookmarks

Posting Permissions

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