Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Dynamic Table listing

Status
Not open for further replies.

gmagerr

Technical User
Aug 11, 2001
323
US
Hi guys, i'm trying to create a form where you can enter the name of the table you want to view and it will list everything in the table.. I'm taking the name typed into the table name on the first form and trying to insert it into an sql statement on the second form. it's not working here's what i have...

Dim strSQL
strSQL = "SELECT * FROM Table WHERE Table = '" & Request.Form("Table") & "'"

Response.Write strSQL 'to check for errors

Dim objConn
Set objConn = Server.CreateObject("ADODB.Connection")
objConn.Open "DSN=Employees2"

Dim objRS
Set objRS = Server.CreateObject("ADODB.Recordset")
objRS.Open strSQL, objConn

Dim fCount, i
fCount = objRS.Fields.Count - 1
Response.Write &quot;<table border=1><tr bgcolor='#EEEEEE'>&quot;

for i=0 to fCount
Response.Write &quot;<th>&quot; & objRS(i).name & &quot;</th>&quot;
next
Response.Write &quot;</tr>&quot;
While Not objRS.EOF
Response.Write &quot;<tr>&quot;
for i=0 to fCount
Response.Write &quot;<td> &quot; & objRS(i).value & &quot;</td>&quot;
next
Response.Write &quot;</tr>&quot;
objRS.MoveNext
Wend
Response.Write &quot;</table>&quot;

objRS.Close
Set objRS = Nothing
objConn.Close
Set objConn = Nothing


The error i'm gettint is in the SQL statement the Employees2 entered from the first form is being inserted as 'Employees2' any way to fix this? also i'd like to be able to insert the DSN on the first form and have it dynamic as well... thanks in advance guys.
 
strSQL = &quot;SELECT * FROM Table WHERE Table = '&quot; & Request.Form(&quot;Table&quot;) & &quot;'&quot;


to:

strSQL = &quot;SELECT * FROM &quot; & request.form(&quot;table&quot;)
penny.gif
penny.gif
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top