473,562 Members | 3,101 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

ASP SQL Table - Need Help!!!

3 New Member
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 1085
jhardman
3,406 Recognized Expert Specialist
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
antiredcap
3 New Member
Yes... thanks a lot!!
Sep 20 '07 #3

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

Similar topics

7
6489
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 generate the invoice records, I have an initial table which are basically Day Records. The task that I would like to complete is to select all records...
9
3115
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 SUBSTRING(ProductName, 1, CHARINDEX('(', ProductName)-2). I can get this result, but I had to use several views (totally inefficient). I think this can be...
9
1597
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 getting nowhere. I want to create an XML schema (XSD) for a dataset/datatable using the XML designer.
1
5828
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 be more complicated there can be in the same record in second table with status 0 and 1 (second table is something like log) in oracle I can do:...
13
5770
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 CatalogImage where imgID also needs to be placed. Below is my code behind to carry the catID using the Select @@Identity and insert imgID to the bridge...
1
1269
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: Issue id, customer, status of the issue (either unresolved or resolved), description, etc. Table two includes: customer
1
1184
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 like userID, first_name, last_name, and such. The authorization_users table contains a permID which is the key from the reports table, userID, and a...
1
2941
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" /> <meta name="description" content="Heaventure Sole-Proprietor"> <meta name="keywords" content="Heaventure, Company, Heaventure Company, Singapore"...
3
2347
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
7648
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
0
7863
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
1
7620
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
0
7931
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
0
6213
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
1
5473
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
0
5189
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
0
3618
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
0
3602
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?

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.