Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 3 of 3
  1. #1
    New to the CF scene
    Join Date
    Apr 2006
    Posts
    7
    Thanks
    0
    Thanked 0 Times in 0 Posts

    "SELECT" statement & conditions..

    I'm using SQL/ASP, I'm trying to pull a record from one mdb table and copy it to another mdb table, but i'm having some problems.. here is my code:

    Line 1>Sql_sel = "SELECT Top 1 CUSTID FROM cust ORDER by CUSTID DESC"
    Line 2>CUSTID = Sql_sel
    Line 3>response.write(CUSTID)

    Line 1, CUSTID being the ID field, cust being the table which holds the records.
    Line 3, is a test to see if it pulls the right data, unfortunately it doesn't infact where i was expecting to see the lastest CUSTID displayed it infact just displays Line 1 as i have written it. This mkaes me beleive that i have made a simple syntax error.. can anyone spot any faults?

  • #2
    Senior Coder
    Join Date
    Jun 2002
    Location
    Zwolle, The Netherlands
    Posts
    1,120
    Thanks
    2
    Thanked 31 Times in 31 Posts
    you might want to check here: http://www.w3schools.com/ado/ado_examples.asp to see what you need to extract and manipulate data in a database from an asp page. There are some simple examples. Use and modify them to achieve your desired results
    I am the luckiest man in the world

  • #3
    Registered User
    Join Date
    Jan 2006
    Posts
    130
    Thanks
    0
    Thanked 0 Times in 0 Posts
    You're missing your connection to the Database and the Recordset to pull the data back. Almost looks like you're trying to do it in PHP fashion...completely different...Here is something like I use for a connection to the DB...

    'Set the Connection Object --------------------------------------------------------------
    'Define connection object
    Dim conn
    SET conn = Server.CreateObject("ADODB.Connection")
    conn.ConnectionString = "Provider=SQLOLEDB.1;Password=password;Persist Security Info=True;User ID=userid;Initial Catalog=table;Data Source=database"
    conn.CommandTimeout = 30
    conn.ConnectionTimeout = 30
    conn.open
    '----------------------------------------------------------------------------------------


    Once that is setup then you would do...

    Dim Sql_sel, RS
    'Set up recordset
    Set RS = Server.CreatObject("ADODB.Recordset")
    Sql_sel = "SELECT Top 1 CUSTID FROM cust ORDER by CUSTID DESC"

    RS.Open Sql_sel, conn

    Response.Write RS.Fields("CUSTID")


  •  

    Posting Permissions

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