Making queries more dynamic...

Results 1 to 2 of 2

Thread: Making queries more dynamic...

  1. #1
    Emiel Langeberg Guest

    Default Making queries more dynamic...

    Is there any way I can request a table from a database with the use of a variable?<BR><BR><BR>&#060;%<BR>dim tablename<BR>tablename = book_tbl<BR>select * from tablename<BR>%&#062;<BR><BR><BR>How can I make this work? (I know this code looks stupid like this, but it would help me a lot if I knew how to make the SQL-queries a bit more dynamic).<BR><BR>Does anyone have any other suggestions how I can make queries more dynamic?<BR><BR>Can someone help this &#039beginner in ASP&#039?

  2. #2
    Vivek Nama Guest

    Default RE: Making queries more dynamic...

    you could call a stored procedure passing the name of the table as parameter and using the execute statement inside the PROC to run a dynamically created query<BR>else you can use connection.execute "select * from " & request(table name) if you are getting it from a previous page<BR>or if you have to conditionally select from a list of tables use<BR>SELECT CASE statement in your server side script with hard coded SQL statements

Posting Permissions

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