ASP.NET - How to display Recordset

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • ziycon
    Contributor
    • Sep 2008
    • 384

    ASP.NET - How to display Recordset

    I have the below code but i can't display the recordset, maybe i'm doing it way to complicated!?
    Code:
    <% DIM strDataSourceName, objConn
    
    Set objConn = Server.CreateObject("ADODB.Connection")
    
    strDataSourceName="Provider=SQLOLEDB;Data Source=localhost,1433;Network Library=DBMSSOCN;Initial Catalog=testdb;User ID=testuser;Password=12345678;"
    
    objConn.connectionstring = strDataSourceName
    objConn.Open 
    
    DIM mySQL
    mySQL = "SELECT message FROM message_tbl WHERE id=1"
    
    DIM objRS
    Set objRS = Server.CreateObject("ADODB.Recordset")
    objRS.Open mySQL, objConn %>
    <html>
    <head>
    <title>ASP Test Page</title>
    </head>
    <body>
    <% response.write() %>
    </body>
    </html>
    <% objRS.Close
    objConn.Close %>
  • GazMathias
    Recognized Expert New Member
    • Oct 2008
    • 228

    #2
    You are not telling Response.Write what to write.

    Try
    Code:
    Response.Write objRS("message")
    or

    Code:
    <%=objRS("message")%>

    Comment

    • jhardman
      Recognized Expert Specialist
      • Jan 2007
      • 3405

      #3
      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

      Comment

      Working...