#1
  1. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Oct 2003
    Location
    sydney, australia
    Posts
    20
    Rep Power
    0

    sql query in an asp page


    hi..i am trying to read in record from a databse located in the web server...
    i am trying to do this sql query in an asp page..so this is an asp code...i have written the code as this

    <code>
    <%

    mySQL1 = "select b.BookingNum,c.Title,c.Fname,c.Lname,c.HouseNum,c.Street,c.Suburb,c.State,c.Postcode,c.Phone,"
    mySQL1 = mySQL1 & "RR.RmType,RB.RoomNum,s.ServiceType from Customer c,Bookings b,RoomBooking RB,"
    mySQL1 = mySQL1 & "RoomRates RR, SuppBooking SB, Services s where c.CustomerID=b.CustomerID and "
    mySQL1 = mySQL1 & "b.BookingNum=RB.BookingNum and SB.SuppServiceID=s.SuppServiceID and RB.RmTypeCode=RR.RmTypeCode and "
    mySQL1 = mySQL1 & "b.BookingNum= '" & bnn & "'"



    %>
    </code>

    just asking that is there any thing wrong with this sql query....because my page isn;t showing...and i donno if it is the right way to connect different tables...please help
  2. #2
  3. Banned ;)
    Devshed Supreme Being (6500+ posts)

    Join Date
    Nov 2001
    Location
    Woodland Hills, Los Angeles County, California, USA
    Posts
    9,638
    Rep Power
    4247
    The best way to debug this would be to print mySQL1 to the browser, after you've completed constructing the query. Then, run the query from query analyzer and see if it returns any results. That will tell you if you're constructing the query properly or not.
    Up the Irons
    What Would Jimi Do? Smash amps. Burn guitar. Take the groupies home.
    "Death Before Dishonour, my Friends!!" - Bruce D ickinson, Iron Maiden Aug 20, 2005 @ OzzFest
    Down with Sharon Osbourne

    "I wouldn't hire a butcher to fix my car. I also wouldn't hire a marketing firm to build my website." - Nilpo
  4. #3
  5. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Nov 2003
    Location
    italy
    Posts
    5
    Rep Power
    0
    HI sfaiz2001
    It seems to be a "JOIN" problem. If i've had correctly understood, you're triing to brig data from different tables (C,RR,RB,SB,S). I suggest you to proceed as follows:
    1) Build a VIEW in sql that joins data you need and test if the data you want are or not correctly displayed.
    2) Simply recall the view by the following code:
    <code>
    <%mySQL1 = "SELECT * FROM VIEW_NAME"%>
    </code>
    WHere VIEW_NAME is the above mentioned view.
    Hope this could help.
    Regards.

IMN logo majestic logo threadwatch logo seochat tools logo