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 TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Display question

Status
Not open for further replies.
Feb 29, 2004
75
US
I have the following ASP code which basically goes into the main database and lists all the databases tables. However i dont know how to output those results using the Response.write command. How would I have to go about that. Thanks in advance

-CODE- mydbdetails.asp
<%
Set dbconn = Server.CreateObject("ADODB.Connection")
dbconn.open("Provider=SQLOLEDB; Data Source=sq111.crystech.com; Initial Catalog=mydbtest; User ID=mydbtest; Password=dotheftp; network=dbmcn")

strSQL="use maindbtest" &_
"go" &_
"select *" &_
"from INFORMATION_SCHEMA.COLUMNS" &_
"order by TABLE_NAME"

Response.Write("Done")
%>
 
I am running this on SQL server so it is related to the forum
 
get the resultset into a recordset by executing the query using

set rdset = dbconn.Execute(strSQL)

After that loop the recordset until EOF

<% While rdset.EOF = False %>

<% Display records using Response.Write % >


I have not written the exact code , but this should help.

Regards
Nikhil




 
Hey Nikhil thanks alot for that I have the error

Microsoft OLE DB Provider for SQL Server error '80004005'

Could not locate entry in sysdatabases for database 'maindbtestgoselect'. No entry found with that name. Make sure that the name is entered correctly.

/maindb/mydbdetails.asp, line 11

I am using the following code

<%
Set dbconn = Server.CreateObject("ADODB.Connection")
dbconn.open("Provider=SQLOLEDB; Data Source=sq111.crystech.com; Initial Catalog=mydbtest; User ID=mydbtest; Password=dotheftp; network=dbmcn")

strSQL="use maindbtest" &_
"go" &_
"select *" &_
"from INFORMATION_SCHEMA.COLUMNS" &_
"order by TABLE_NAME"

set rdset = dbconn.Execute(strSQL)
While rdset.EOF = False

Response.Write(rdset)
wend
%>
 
I am getting the follwoing error:
----ERROR-------------------
Microsoft OLE DB Provider for SQL Server error '80004005'
Could not locate entry in sysdatabases for database 'maindbtestselect'. No entry found with that name. Make sure that the name is entered correctly.
/mydbdetails.asp, line 10
--------------------------
The code i am using is as following. my question is why is it saying for 'maindbtestselect?

-----CODE for mydbdetails.asp -------------
<%
Set dbconn = Server.CreateObject("ADODB.Connection")
dbconn.open("Provider=SQlEDB; Data Source=sq6.crysttech.com; Initial Catalog=mydb; User ID=testdb; Password=db123; network=dbmssocn")


strSQL="use maindtest" &_
"select distinct table_name" &_
"from INFORMATION_SCHEMA.COLUMS" &_
"order by table_name"
set rs=dbconn.execute(strSQL)
reponse.write "List of Table" & "<br>"
while not rs.eof
response.write(rs("table_name"))
response.write "<br>"
rs.movenext
wend
%>
 

try sticking spaces in the select statement ...

strSQL="use maindbtest " &_
"go " &_
"select * " &_
"from INFORMATION_SCHEMA.COLUMNS " &_
"order by TABLE_NAME"

the &_ only tells your compiler that the code continues over to the next line :)

~ Remember - Nothing is Fool Proof to a Talented Fool ~
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top