473,406 Members | 2,208 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,406 software developers and data experts.

ASP SQL Table - Need Help!!!

I need to display a sql table on a asp page with a dropdown list.
The dropdown needs to be connected to SQL, when a table name gets selected from the dropdown the whole table needs to be displayed on the ap page.
Sep 18 '07 #1
2 1084
jhardman
3,406 Expert 2GB
This is actually very easy, except possibly the dropdown list part. Anyone else know how to populate the dropdown list with every table name in a db?

the rest of it looks like this:
Expand|Select|Wrap|Line Numbers
  1. dim conn, rs, query, x
  2.  
  3. query = "SELECT * FROM " & request("tableDropDown")
  4. 'get every field from the table specified in the dropdown
  5.  
  6. set conn = server.createObject("adodb.connection")
  7. conn.open "myDSN1" 'this should be your system DSN for this db, or if you
  8.    'don't use a DSN, you can modify this line to include the path to the db file
  9.  
  10. set rs = server.createObject("adodb.recordet")
  11. rs.open query, conn
  12. 'populates the recordset "rs" from the data specified in "query" using the
  13. ' connection specified in "conn"
  14.  
  15. 'make a header row in the table
  16. response.write "<table><tr>"
  17. for each x in rs.fields
  18.    response.write "<th>" & x.name & "</th>" & vbNewLine
  19. next
  20. response.write "</tr>"
  21.  
  22. 'the body of the table is the actual data
  23. do until rs.eof 'keep going until we get to the end of the recordset
  24.    response.write "<tr>" 'each record makes up one table row
  25.    for each x in rs.fields
  26.       response.write "<td>" & x.value & "</td>" & vbNewLine
  27.       'the value in each field makes up the values in each cell of the table
  28.    next
  29.    response.write "</tr>"
  30.    rs.movenext 'go to the next record
  31. loop
  32. response.write "</table>"
Normally I try not to give whole code answers since it is important for the askers to work out how to solve problems, but this was an approach that really changed my perspective and simplified how I displayed tables. Does everything make sense?

Jared
Sep 18 '07 #2
Yes... thanks a lot!!
Sep 20 '07 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

7
by: Aleem | last post by:
I need help in writing a stored procedure on SQL Server 2000. Basically the stored procedure's primary task is to generate invoice records and insert the records in a invoice table. In order to...
9
by: netpurpose | last post by:
I need to extract data from this table to find the lowest prices of each product as of today. The product will be listed/grouped by the name only, discarding the product code - I use...
9
by: Tony Girgenti | last post by:
Hello I developed and tested a web application using VS.NET 2003, VB, .NET Framework 1.1.4322, ASP.NET 1.1.4322 and IIS5.1. It uses a web form. I tried doing this without any help, but i'm...
1
by: bpforte | last post by:
Hello, I need help with building query, basically I need to select all records from one table that don't exists in second table with status 1, but they can exists in second table with status 0, to...
13
by: PinkBishop | last post by:
I am using VS 2005 with a formview control trying to insert a record to my access db. The data is submitted to the main table no problem, but I need to carry the catID to the bridge table...
1
by: jkincaid | last post by:
I need help on a simple database, I have limited ACCESS skills. Here's my dilemma: I have 2 tables: Table one is customer issues Table two is the particular customer Table one includes:...
1
by: CoolBreeze812 | last post by:
Hi, I need help with a query and I'm having trouble getting it formed correctly. I have 3 tables: users, authorization_users, and reports. The user table contains a bunch of users with fields...
1
crystal2005
by: crystal2005 | last post by:
Hi i encounterd some problem when i implement CSS for rounded Corner table. Need help please... :D <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />...
3
allingame
by: allingame | last post by:
Need help with append and delete duplicates I have tables namely 1)emp, 2)time and 3)payroll TABLE emp ssn text U]PK name text
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.