Connecting Tech Pros Worldwide Forums | Help | Site Map

ASP.NET - How to display Recordset

Familiar Sight
 
Join Date: Sep 2008
Posts: 253
#1: Oct 22 '08
I have the below code but i can't display the recordset, maybe i'm doing it way to complicated!?
Expand|Select|Wrap|Line Numbers
  1. <% DIM strDataSourceName, objConn
  2.  
  3. Set objConn = Server.CreateObject("ADODB.Connection")
  4.  
  5. strDataSourceName="Provider=SQLOLEDB;Data Source=localhost,1433;Network Library=DBMSSOCN;Initial Catalog=testdb;User ID=testuser;Password=12345678;"
  6.  
  7. objConn.connectionstring = strDataSourceName
  8. objConn.Open 
  9.  
  10. DIM mySQL
  11. mySQL = "SELECT message FROM message_tbl WHERE id=1"
  12.  
  13. DIM objRS
  14. Set objRS = Server.CreateObject("ADODB.Recordset")
  15. objRS.Open mySQL, objConn %>
  16. <html>
  17. <head>
  18. <title>ASP Test Page</title>
  19. </head>
  20. <body>
  21. <% response.write() %>
  22. </body>
  23. </html>
  24. <% objRS.Close
  25. objConn.Close %>

GazMathias's Avatar
Expert
 
Join Date: Oct 2008
Location: Bristol, United Kingdom
Posts: 143
#2: Oct 22 '08

re: ASP.NET - How to display Recordset


You are not telling Response.Write what to write.

Try
Expand|Select|Wrap|Line Numbers
  1. Response.Write objRS("message")
or

Expand|Select|Wrap|Line Numbers
  1. <%=objRS("message")%>
jhardman's Avatar
Moderator
 
Join Date: Jan 2007
Location: logan, utah
Posts: 2,690
#3: Oct 23 '08

re: ASP.NET - How to display Recordset


I'm confused, you say in your title that this is an ASP.NET question, yet you posted it in the "classic" ASP section, and the code sure looks like "classic" ASP written in VBScript. Perhaps the confusion stems from not knowing which version of ASP you are using.

Jared
Reply