Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 SQL SELECT - Not able to view Table with ASP Code?

Author  Topic 

shawn.bordeaux
Starting Member

1 Post

Posted - 2008-10-22 : 16:38:09
I have a form that is sending information to a SQL database into a table named "sponsors" - All of this is working fine. However I am trying to create a page that will display the entire table when visited. I have posted the code I am using below which is in the Body of the page I have created with the exception of the included file which is above the HTML link. The variable DataConn comes from the included DBconnect file, which is the same one I use to insert the info from the form page which once again works fine.

<!--#include file="../includes/database/dbconnect.asp"-->

<%
dim strSQL_Select
strSQL_Select = " SELECT * FROM sponsors"
DataConn.execute(strSQL_Select)
%>

The page loads fine however it is blank, no tables listed just a blank page. If you know where I am going wrong please let me know. I am a complete newbie to SQL.

THank you!

shawn.bordeaux@justrightautosales.com

webfred
Master Smack Fu Yak Hacker

8781 Posts

Posted - 2008-10-22 : 17:10:24
I don't know anything about asp code.
select * from sponsors looks ok so far.
Is there any binding to a asp-data-control / web control to display the data?
Looking at your inserts to table sponsors, is there anything like DBName.dbo.sponsors which means the connection was made to another Database on same server?
Is there a way in asp to take care of sql errors / display sql errors?

Webfred


No, you're never too old to Yak'n'Roll if you're too young to die.
Go to Top of Page

hanbingl
Aged Yak Warrior

652 Posts

Posted - 2008-10-22 : 17:16:19
You need to display your record sets.

SET rs = DataConn.execute(strSQL_Select)

do while not rs.eof
RESPONSE.WRITE(.....)
'DISPLAY YOUR RS columns FOR EXAMPLE: RS(0) is column 1 or RS("COL1")
rs.movenext
loop

Good'ol Days
Go to Top of Page

hanbingl
Aged Yak Warrior

652 Posts

Posted - 2008-10-22 : 17:18:28
ooh
Don't forget to close your connection after you display your data.
RS.Close
Set RS = Nothing
DataConn.Close
Set DataConn = Nothing
Go to Top of Page

hanbingl
Aged Yak Warrior

652 Posts

Posted - 2008-10-22 : 18:39:08
quote:
Originally posted by webfred

I don't know anything about asp code.
select * from sponsors looks ok so far.
Is there any binding to a asp-data-control / web control to display the data?
Looking at your inserts to table sponsors, is there anything like DBName.dbo.sponsors which means the connection was made to another Database on same server?
Is there a way in asp to take care of sql errors / display sql errors?

Webfred


No, you're never too old to Yak'n'Roll if you're too young to die.


Depends on which dev tool you use. Microsoft VS6.0 comes with Visual Interdev for ASP development. ColdFusion has some pretty good tools as well.
Go to Top of Page
   

- Advertisement -